From 5c992b022b44959fe45c95c528483408d70f620e Mon Sep 17 00:00:00 2001 From: Shayne Krause <17761988+Yorgei@users.noreply.github.com> Date: Wed, 16 Apr 2025 11:30:12 +1000 Subject: [PATCH] Create node-build-push.yaml --- .gitea/workflows/node-build-push.yaml | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .gitea/workflows/node-build-push.yaml diff --git a/.gitea/workflows/node-build-push.yaml b/.gitea/workflows/node-build-push.yaml new file mode 100644 index 0000000..ec27481 --- /dev/null +++ b/.gitea/workflows/node-build-push.yaml @@ -0,0 +1,63 @@ +# Default for node apps. +name: Build and Push Docker Image +on: + push: + branches: + - main # Trigger on pushes to the main branch + +jobs: + build-and-push: + # Use a runner label defined in your runner's environment variables + runs-on: ubuntu-latest + env: + GIT_SSL_NO_VERIFY: "1" + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Optional: Login step if your registry requires authentication + - name: Log in to local registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.REGISTRY_URL }} # Use the same IP as in daemon.json + username: ${{ secrets.REGISTRY_USERNAME }} # Store credentials in Gitea secrets + password: ${{ secrets.REGISTRY_PASSWORD }} # Store credentials in Gitea secrets + + - name: Determine Image Tag + id: meta + run: | + # Use Git tag if present, otherwise use 'latest' for default branch + if [[ ${GITHUB_REF} == refs/tags/* ]]; then + TAG=${GITHUB_REF#refs/tags/} + else + TAG=latest + fi + echo "tag=${TAG}" >> $GITHUB_OUTPUT + echo "Using tag: ${TAG}" + + - name: Build and Push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + # IMPORTANT: Tag format is REGISTRY_HOST:PORT/IMAGE_NAME:TAG + tags: ${{ secrets.REGISTRY_URL }}/${{ github.repository }}:${{ steps.meta.outputs.tag }} + # Optional: Add build arguments + # build-args: | + # ARG_NAME=value + cache-from: type=gha # Optional: Enable build cache + cache-to: type=gha,mode=max # Optional: Enable build cache + + - name: Send webhook notification + if: always() + run: | + status_code=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"status": "${{ job.status }}", "repo":"${{ github.repository }}"}' \ + ${{ secrets.WEBHOOK_URL }}) + echo "Webhook HTTP status code: $status_code"