Docker push when latest and releases pushed #60799
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: Docker push when latest and releases pushed | |
on: | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
schedule: | |
- cron: '*/30 * * * *' | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git fetch --unshallow | |
- name: Get latest tag | |
id: latest_tag | |
run: | | |
ruby -e 'puts "::set-output name=latest_tag::#{`git tag`.each_line.map{|t| begin {raw_tag: t, gver: Gem::Version::new(t.sub(/^v/, ""))}; rescue; nil end}.compact.max_by{|v| v[:gver]}[:raw_tag]}"' | |
- name: Checkout latest tag | |
run: | | |
set -eu | |
echo "Latest tag: ${{ steps.latest_tag.outputs.latest_tag }}" | |
git reset --hard ${{ steps.latest_tag.outputs.latest_tag }} | |
git status | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: nwtgck | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 | |
push: true | |
tags: nwtgck/rich-piping-server:latest,nwtgck/rich-piping-server:${{ steps.latest_tag.outputs.latest_tag }} |