# 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' - 'v202[0-9].[0-9].x' tags: - 'v*' pull_request: 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@1f401f745bf57e30b3a2800ad308a87d2ebdf14b if: ${{ github.repository_owner == 'freifunk-gluon' && github.event_name == 'push' }} 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@fdf7f43ecf7c1a5c7afe936410233728a8c2d9c2 with: context: ./contrib/docker push: ${{ github.repository_owner == 'freifunk-gluon' && github.event_name == 'push' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}