build #884
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
# This is a basic workflow to help you get started with Actions | |
name: build | |
# Controls when the action will run. | |
on: | |
schedule: | |
- cron: '33 13 * * 1-5' | |
push: | |
branches: [ main ] | |
# Publish semver tags as releases. | |
tags: [ 'v*.*.*' ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
checkTags: | |
name: Check Tags | |
runs-on: "ubuntu-latest" | |
outputs: | |
latest_version: ${{ steps.getTags.outputs.latest_version }} | |
local_version: ${{ steps.getTags.outputs.local_version }} | |
build: ${{ steps.getTags.outputs.build }} | |
steps: | |
- name: Get Tags | |
id: getTags | |
run: | | |
echo "Getting all releases" | |
curl https://api.github.com/repos/aws/aws-cli/tags | jq -r '.[0].name' | grep -v dev > releases && cat releases | head -n1 > latest | |
curl https://api.github.com/repos/WAOptics/aws-docker-toolkit/tags | jq -r '.[0].name' | grep -v dev > releases && cat releases | head -n1 > local_version | |
if [ $local_version != $latest_version ]; then echo "true" > build ; fi | |
echo "latest_version=`cat latest`" >> $GITHUB_OUTPUT | |
echo "local_version=`cat local_version`" >> $GITHUB_OUTPUT | |
echo "build=`cat build`" >> $GITHUB_OUTPUT | |
build: | |
name: Build | |
needs: checkTags | |
runs-on: ubuntu-latest | |
outputs: | |
latest_version: ${{ steps.latestTag.outputs.latest_version }} | |
steps: | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Validate Build | |
id: latestTag | |
if: ${{ needs.checkTags.outputs.build }} == "true" | |
run: | | |
echo Building Version = ${{ needs.checkTags.outputs.latest_version }} | |
echo ${{ needs.checkTags.outputs.latest_version }} > latest | |
echo "latest_version=`cat latest`" >> $GITHUB_OUTPUT | |
- | |
name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
if: ${{ needs.checkTags.outputs.build }} == "true" | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: richarvey/awscli:latest, richarvey/awscli:${{ needs.checkTags.outputs.latest_version }} | |
- | |
name: Image digest | |
if: ${{ env.build == 'true' }} | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
tag: | |
name: Tag | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Tag Release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "${{ needs.build.outputs.latest_version }}" | |
prerelease: false | |
title: "${{ needs.build.outputs.latest_version }}" | |
files: | | |
* |