Update build.yml #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| schedule: | |
| - cron: '0 17 * * 1' | |
| push: | |
| branches: [ 'main' ] | |
| tags: [ 'v*' ] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY_DOCKER: docker.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/arganium | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - dockerfile: Dockerfile | |
| tag_suffix: '' | |
| is_main: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Login to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract Docker metadata | |
| id: meta | |
| if: ${{ matrix.is_main }} | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=semver,pattern={{version}} | |
| - name: Build and push Docker images | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| # If it's the main image (is_main: true), use the complex tags from 'meta' | |
| tags: ${{ matrix.is_main && steps.meta.outputs.tags || format('{0}:{1}', env.IMAGE_NAME, matrix.tag_suffix) }} | |
| # Only apply 'meta' labels to the main image | |
| labels: ${{ matrix.is_main && steps.meta.outputs.labels || '' }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |