Build & Publish #183
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 & Publish" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 5 * * 5" | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Get latest release tag | |
id: latestrelease | |
run: | | |
RELEASE_TAG=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" | jq -r '.tag_name') | |
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT" | |
echo "Latest release: $RELEASE_TAG" | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.latestrelease.outputs.tag }} | |
- | |
name: Set variables | |
run: | | |
IMAGE=$(jq -er '.image' < config.json) | |
VERSION=$(jq -er '.version' < config.json) | |
TAG=$(jq -er '"\(.image):\(.version)"' < config.json) | |
echo "IMAGE=$IMAGE" >> $GITHUB_ENV # ${{ env.IMAGE }} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV # ${{ env.VERSION }} | |
echo "TAG=$TAG" >> $GITHUB_ENV # ${{ env.TAG }} | |
- | |
name: Set up QEMU | |
uses: docker/[email protected] | |
- | |
name: Set up Docker Buildx | |
id: buildx | |
uses: docker/[email protected] | |
- | |
name: Available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
# - | |
# name: Cache Docker layers | |
# uses: actions/cache@v2 | |
# with: | |
# path: /tmp/.buildx-cache | |
# key: ${{ runner.os }}-buildx-${{ github.sha }} | |
# restore-keys: | | |
# ${{ runner.os }}-buildx- | |
- | |
name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- | |
name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
provenance: false | |
push: true | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
tags: | | |
${{ env.TAG }} | |
${{ env.IMAGE }}:latest | |
# cache-from: type=local,src=/tmp/.buildx-cache | |
# cache-to: type=local,dest=/tmp/.buildx-cache |