Skip to content

Check for Updates #40395

Check for Updates

Check for Updates #40395

name: "Check for Updates"
on:
schedule:
- cron: "*/15 * * * *" # Every 15 mins
workflow_dispatch:
create:
tags:
- "v[0-9]+"
jobs:
# Find out what version of AMP exists online right now.
get_latest_version:
name: "Get Latest Version"
runs-on: ubuntu-latest
outputs:
amp_core_version: ${{ steps.parse.outputs.amp_core_version }}
amp_instmgr_version: ${{ steps.parse.outputs.amp_instmgr_version }}
steps:
- name: "Download AMP Versions"
run: wget https://cubecoders.com/AMPVersions.json -O /tmp/AMPVersions.json
- name: "Parse Versions"
id: parse
run: |
echo "::set-output name=amp_core_version::$(jq -r '.AMPCore' /tmp/AMPVersions.json | sed -e 's/\.//g')"
echo "::set-output name=amp_instmgr_version::$(jq -r '.InstanceManagerCLI' /tmp/AMPVersions.json | sed -e 's/\.//g')"
# Find out when the latest version of AMP was modified.
# Sometimes patches are released under the same version, so only this value will change.
get_last_modified:
name: "Get Last Modified"
runs-on: ubuntu-latest
outputs:
amp_last_modified: ${{ steps.parse.outputs.amp_last_modified }}
steps:
- name: "Get Last Modified"
id: parse
# Converts the last-modified header to seconds since epoch.
run: echo "::set-output name=amp_last_modified::$(curl https://cubecoders.com/Downloads/AMP_Latest.zip --head --silent | awk 'match($0, /last-modified:\s+(.+)\s+/, a) {print a[1]}' | date -f - +%s)"
# Determine if we have a tag for this combination of version and last-modified.
check_for_tag:
name: "Check for Tag"
runs-on: ubuntu-latest
needs: [ get_latest_version, get_last_modified ]
outputs:
tag_exists: ${{ steps.check_for_tag.outputs.tag_exists }}
git_release_version: ${{ steps.get_git_version.outputs.git_latest_release_version }}
amp_core_version: ${{ needs.get_latest_version.outputs.amp_core_version }}
amp_instmgr_version: ${{ needs.get_latest_version.outputs.amp_instmgr_version }}
amp_last_modified: ${{ needs.get_last_modified.outputs.amp_last_modified }}
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Determine Latest Release Version"
id: get_git_version
run: echo "::set-output name=git_latest_release_version::$(git tag -l --sort=-creatordate | grep -E '^v?[0-9]+$' -m 1)"
- name: "Compose Expected Tag"
id: compose_tag
run: echo "::set-output name=expected_tag::${{steps.get_git_version.outputs.git_latest_release_version}}-ampcore${{needs.get_latest_version.outputs.amp_core_version}}-ampinstmgr${{needs.get_latest_version.outputs.amp_instmgr_version}}-${{needs.get_last_modified.outputs.amp_last_modified}}"
- name: "Check for Expected Tag"
id: check_for_tag
run: echo "::set-output name=tag_exists::$(git tag | grep -q ${{steps.compose_tag.outputs.expected_tag}} && echo '1' || echo '0')"
build:
name: "Build"
needs: [ check_for_tag ]
if: ${{ needs.check_for_tag.outputs.tag_exists == '0' && github.ref == 'refs/heads/master' }}
uses: MitchTalmadge/AMP-Dockerized/.github/workflows/build.yml@master
with:
for_deploy: true
deploy:
name: "Deploy"
needs: [ build, check_for_tag ]
uses: MitchTalmadge/AMP-dockerized/.github/workflows/deploy-prod.yml@master
with:
git_release_version: ${{ needs.check_for_tag.outputs.git_release_version }}
amp_core_version: ${{ needs.check_for_tag.outputs.amp_core_version }}
amp_instmgr_version: ${{ needs.check_for_tag.outputs.amp_instmgr_version }}
amp_last_modified: ${{ needs.check_for_tag.outputs.amp_last_modified }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}