From 19454b8a703ed5a9d7f05508137049e9b360c60f Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Mon, 30 Sep 2024 22:53:41 -0400 Subject: [PATCH] Add workflow to build and push Docker image --- .gitea/workflows/push.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitea/workflows/push.yaml diff --git a/.gitea/workflows/push.yaml b/.gitea/workflows/push.yaml new file mode 100644 index 0000000..b7adfe8 --- /dev/null +++ b/.gitea/workflows/push.yaml @@ -0,0 +1,36 @@ +name: Push Workflows +on: push + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Gitea container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.registry }} + username: ${{ env.actions_user }} + password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} + - name: Get Image Name + id: get-image-name + run: | + echo "IMAGE_NAME=$(echo ${{ env.registry }}/${{ gitea.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: "${{ steps.get-image-name.outputs.IMAGE_NAME }}:${{ gitea.sha }}" + cache-from: type=registry,ref=${{ steps.get-image-name.outputs.IMAGE_NAME }}:${{ gitea.sha }} + cache-to: type=inline + - name: Build and push Docker image with "latest" tag + uses: docker/build-push-action@v5 + if: gitea.ref == 'refs/heads/main' + with: + push: true + tags: "${{ steps.get-image-name.outputs.IMAGE_NAME }}:latest" + cache-from: type=registry,ref=${{ steps.get-image-name.outputs.IMAGE_NAME }}:latest + cache-to: type=inline