diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..e7445ae --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,68 @@ +name: Build and Push Docker Image + +# Define when this workflow will run +on: + push: + branches: + - master # Trigger on pushes to master branch + tags: + - '[0-9]+.[0-9]+.[0-9]+' # Trigger on semantic version tags + paths-ignore: + - 'Cargo.lock' + - 'LICENSE' + - 'README.md' + - 'docker-compose.yml' + workflow_dispatch: # Allow manual triggering of the workflow + +# Define environment variables used throughout the workflow +env: + REGISTRY: git.nadeko.net + IMAGE_NAME: fijxu/inv_sig_helper + +jobs: + build-and-push: + runs-on: runner + + steps: + # Step 1: Check out the repository code + - name: Checkout code + uses: https://github.com/actions/checkout@v3 + + # Step 3: Set up Docker Buildx for enhanced build capabilities + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v3 + + # Step 4: Authenticate with Quay.io registry + - name: Login to Docker Container Registry + uses: https://github.com/docker/login-action@v3.1.0 + with: + registry: git.nadeko.net + username: ${{ secrets.USERNAME }} + password: ${{ secrets.TOKEN }} + + # Step 5: Extract metadata for Docker image tagging and labeling + - name: Extract metadata for Docker + id: meta + uses: https://github.com/docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # Define tagging strategy + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + type=sha,prefix={{branch}}- + # Define labels + labels: | + quay.expires-after=12w + + # Step 6: Build and push the Docker image + - name: Build and push Docker image + uses: https://github.com/docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}