Push docker tag latest (scheduled) #41
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 | |
run-name: Push docker tag ${{ inputs.version || 'latest (scheduled)' }} | |
permissions: | |
contents: read | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Version to set as the published image tag, or "latest" | |
type: string | |
required: true | |
default: latest | |
localstack-version: | |
description: Version of localstack to use as base image tag | |
type: string | |
required: true | |
default: latest | |
schedule: | |
- cron: "30 18 * * *" | |
jobs: | |
build-and-push: | |
name: Build and push | |
runs-on: ubuntu-latest | |
env: | |
LOCALSTACK_VERSION: ${{ inputs.localstack-version || 'latest' }} | |
LOCALSTACK_PERSIST_VERSION: ${{ inputs.version || 'latest' }} | |
steps: | |
- name: Validate major.minor versions match | |
run: | | |
if [[ ! ($LOCALSTACK_PERSIST_VERSION =~ ^([0-9]+\.[0-9]+) && $LOCALSTACK_VERSION == ${BASH_REMATCH[1]}*) ]] | |
then | |
echo "major.minor versions of $LOCALSTACK_VERSION and $LOCALSTACK_PERSIST_VERSION do not match!" | |
exit 1 | |
fi | |
if: ${{ env.LOCALSTACK_PERSIST_VERSION != 'latest' }} | |
- uses: actions/checkout@v3 | |
- run: bash test.sh | |
- run: docker compose logs | |
if: ${{ failure() }} | |
- name: Set semver tags | |
id: tags | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
gresau/localstack-persist | |
flavor: | | |
latest=false | |
tags: | | |
type=semver,pattern={{version}},value=${{ env.LOCALSTACK_PERSIST_VERSION }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ env.LOCALSTACK_PERSIST_VERSION }} | |
type=semver,pattern={{major}},value=${{ env.LOCALSTACK_PERSIST_VERSION }} | |
if: ${{ env.LOCALSTACK_PERSIST_VERSION != 'latest' }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.tags.outputs.tags || 'gresau/localstack-persist:latest' }} | |
build-args: LOCALSTACK_VERSION=${{ env.LOCALSTACK_VERSION }} |