Push container only when main pushed #17
This file contains 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: labs344-build | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- containers/labs344/** | ||
- .github/workflows/labs344-build.yml # Self-trigger | ||
env: | ||
REGISTRY: ghcr.io/bouncmpe | ||
IMAGE_NAME: labs344 | ||
IMAGE_TAG: 2024-2025-1 | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
matrix: | ||
platform: [linux/amd64, linux/arm64] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup QEMU setup | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Log in to the registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: containers/labs344 | ||
platforms: ${{ matrix.platform }} | ||
push: ${{ if github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
Check failure on line 48 in .github/workflows/labs344-build.yml GitHub Actions / labs344-buildInvalid workflow file
|
||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} |