ci: ensure correct repos are used #213
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: Container Registry | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'build-aux/docker/Dockerfile' | |
pull_request: | |
paths: | |
- 'build-aux/docker/Dockerfile' | |
schedule: | |
# Once a week to keep dependencies up to date | |
- cron: 0 0 * * 0 | |
workflow_dispatch: | |
permissions: | |
contents: read | |
env: | |
REGISTRY: ghcr.io | |
USERNAME: ${{ github.actor }} | |
PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
container: | |
name: Container | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Metadata | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
# set latest tag for main branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=branch | |
- name: Login | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.USERNAME }} | |
password: ${{ env.PASSWORD }} | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./build-aux/docker/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} |