update recorder #11
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
# ref: https://github.com/crazy-max/diun/blob/master/.github/workflows/build.yml | |
name: Docker | |
on: | |
push: | |
branches: | |
- 'master' | |
tags: | |
- 'v*' | |
jobs: | |
buildx: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=${{ secrets.DOCKER_IMAGE }} | |
VERSION=latest | |
SHORTREF=${GITHUB_SHA::8} | |
# If this is git tag, use the tag name as a docker tag | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/v} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" | |
# If the VERSION looks like a version number, assume that | |
# this is the most recent version of the image and also | |
# tag it 'latest'. | |
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MAJOR_VERSION=`echo $VERSION | awk '{split($0,a,"."); print a[1]}'` | |
MINOR_VERSION=`echo $VERSION | awk '{split($0,a,"."); print a[2]}'` | |
TAGS="$TAGS,${DOCKER_IMAGE}:${MAJOR_VERSION},${DOCKER_IMAGE}:${MAJOR_VERSION}.${MINOR_VERSION},${DOCKER_IMAGE}:latest" | |
fi | |
# Set output parameters. | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT | |
echo "docker_platforms=linux/amd64,linux/arm/v7,linux/arm64" >> $GITHUB_OUTPUT | |
- name: Environment | |
run: | | |
echo home=$HOME | |
echo git_ref=$GITHUB_REF | |
echo git_sha=$GITHUB_SHA | |
echo image=${{ steps.prepare.outputs.docker_image }} | |
echo tags=${{ steps.prepare.outputs.tags }} | |
echo platforms=${{ steps.prepare.outputs.docker_platforms }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Login | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: ${{ steps.prepare.outputs.docker_platforms }} | |
push: true | |
tags: ${{ steps.prepare.outputs.tags }} |