Updated build file #17
Workflow file for this run
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: Build | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
# CHOOSE dockerhub repo, username, password | |
- name: Setup Dockerhub repo based on var | |
if: vars.DOCKERHUB_REPO != null | |
run: | | |
echo "DOCKERHUB_REPO=${{vars.DOCKERHUB_REPO}}" >> $GITHUB_ENV | |
- name: Default Dockerhub repo to on project name | |
if: vars.DOCKERHUB_REPO == null | |
run: | | |
echo "DOCKERHUB_REPO=$(basename ${GITHUB_REPOSITORY})" >> $GITHUB_ENV | |
- name: Setup Dockerhub owner based on var | |
if: vars.DOCKERHUB_OWNER != null | |
run: | | |
echo "DOCKERHUB_OWNER=${{vars.DOCKERHUB_OWNER}}" >> $GITHUB_ENV | |
- name: Default Dockerhub owner to dockerhub username | |
if: vars.DOCKERHUB_OWNER == null | |
run: | | |
echo "DOCKERHUB_OWNER=${{secrets.DOCKERHUB_USERNAME}}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DOCKERHUB_OWNER }}/${{ env.DOCKERHUB_REPO }} | |
tags: | | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
type=semver,pattern=v{{major}} | |
type=semver,pattern=v{{version}} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64, linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# Prepare README for Dockerhub | |
- name: Prepare README for dockerhub | |
run: | | |
envsubst < ./README.DOCKER.template.md > ./README.DOCKER.md | |
# Update dockerhub description based on README.DOCKER | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
short-description: ${{ github.event.repository.description }} | |
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.DOCKERHUB_REPO }} | |
# readme-filepath: ./release/artifacts/README.DOCKER.template.md | |
readme-filepath: ./README.DOCKER.template.md |