Skip to content

Allow chris_superuser to be defined by environment variables CHRIS_US… #84

Allow chris_superuser to be defined by environment variables CHRIS_US…

Allow chris_superuser to be defined by environment variables CHRIS_US… #84

Workflow file for this run

name: build
on:
push:
branches: [ master ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ master ]
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Decide image tags
id: info
shell: python
run: |
import os
import itertools
registries = ['docker.io', 'ghcr.io']
repos = ['${{ github.repository }}'.lower()]
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
version = '${{ github.ref_name }}'[1:]
tags = ['latest', version]
else:
tags = []
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'
product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
push = 'true' if tags_csv else 'false'
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'tags={tags_csv}\n')
out.write(f'push={push}\n')
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name == 'push' || github.event_name == 'release'
id: dockerhub_login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.info.outputs.tags }}
push: ${{ steps.info.outputs.push }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v3
if: ${{ steps.info.outputs.push }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ${{ github.event.repository.description }}