-
David Bauer authored
Only push the container to ghcr in case the repository is owned by the freifunk-gluon organization. THis avoids failing CI on forks. Signed-off-by:
David Bauer <mail@david-bauer.net>
David Bauer authoredOnly push the container to ghcr in case the repository is owned by the freifunk-gluon organization. THis avoids failing CI on forks. Signed-off-by:
David Bauer <mail@david-bauer.net>
build-container.yml 1.30 KiB
# Based on the example from https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
name: Create and publish a Docker image
on:
push:
branches:
- 'master'
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: gluon-build
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@b4bedf8053341df3b5a9f9e0f2cf4e79e27360c6
if: ${{ github.repository_owner == 'freifunk-gluon' }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@879dcbb708d40f8b8679d4f7941b938a086e23a7
with:
images: ${{ env.REGISTRY }}/freifunk-gluon/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@4c1b68d83ad20cc1a09620ca477d5bbbb5fa14d0
with:
context: ./contrib/docker
push: ${{ github.repository_owner == 'freifunk-gluon' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}