Push docker tag latest (scheduled) #488
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 | |
env: | |
LOCALSTACK_VERSION: ${{ inputs.localstack-version || 'latest' }} | |
LOCALSTACK_PERSIST_VERSION: ${{ inputs.version || 'latest' }} | |
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: | |
validation: | |
name: Validation | |
runs-on: ubuntu-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@v4 | |
- run: sudo -E python3 test.py | |
- run: sudo -E docker compose logs | |
if: ${{ failure() }} | |
build-and-push: | |
name: Build and push | |
runs-on: ubuntu-latest | |
needs: validation | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set semver tags | |
id: tags | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
gresau/localstack-persist | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=${{ env.LOCALSTACK_PERSIST_VERSION }},priority=1000 | |
type=semver,pattern={{major}}.{{minor}},value=${{ env.LOCALSTACK_PERSIST_VERSION }},enable=${{ env.LOCALSTACK_PERSIST_VERSION != 'latest' }} | |
type=semver,pattern={{major}},value=${{ env.LOCALSTACK_PERSIST_VERSION }},enable=${{ env.LOCALSTACK_PERSIST_VERSION != 'latest' }} | |
- 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_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.tags.outputs.tags }} | |
labels: ${{ steps.tags.outputs.labels }} | |
build-args: LOCALSTACK_VERSION=${{ env.LOCALSTACK_VERSION }} |