This commit is contained in:
@@ -1,19 +1,51 @@
|
|||||||
name: Gitea Actions Demo
|
name: Build & Push Docker Image
|
||||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
run-name: "Build & publish go-micro-service Docker image"
|
||||||
on: [push]
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-Gitea-Actions:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest # ← must match your Gitea Act Runner label
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
# ----------------------------------------------------------
|
||||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
# 1. Check out code
|
||||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
# ----------------------------------------------------------
|
||||||
- name: Check out repository code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
|
||||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
# ----------------------------------------------------------
|
||||||
- name: List files in the repository
|
# 2. Set required variables
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
- name: Set environment variables
|
||||||
run: |
|
run: |
|
||||||
ls ${{ gitea.workspace }}
|
echo "REGISTRY=${{ gitea.server_url }}" >> $GITHUB_ENV
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
echo "IMAGE_NAME=${{ gitea.repository }}" >> $GITHUB_ENV
|
||||||
|
echo "TAG=latest" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# 3. Login to Gitea Container Registry
|
||||||
|
# You must create a secret: GITEA_REGISTRY_TOKEN
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.GITEA_REGISTRY_TOKEN }}" | \
|
||||||
|
docker login ${{ env.REGISTRY }} \
|
||||||
|
-u "${{ gitea.actor }}" --password-stdin
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# 4. Build Docker image from your Dockerfile
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} .
|
||||||
|
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# 5. Push Docker image
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
- name: Push Docker image
|
||||||
|
run: |
|
||||||
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
|
|||||||
Reference in New Issue
Block a user