added centos7 base image definition. (#37) #35
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: Update 'latest' tags on built images | |
on: | |
push: | |
branches: | |
- main | |
# Pushing to test-tag-latest-workflow will | |
# assume a build id of "{github.actor}-test" | |
# and a dest_tag of "{github.actor}-latest", | |
# where '{github.actor} is the github user id of the person | |
# who pushed to the test branch. | |
- test-tag-latest-workflow | |
workflow_dispatch: | |
inputs: | |
build-id: | |
description: The build-id (or any tag) that you want to tag as 'latest' | |
required: true | |
jobs: | |
configure: | |
outputs: | |
build-id: ${{ steps.extract.outputs.build-id }} | |
dest-tag: ${{ steps.extract.outputs.dest-tag }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract build-id | |
# This checks for the existence of the string: `(build-id: foo)` | |
# (where `foo` is some unique identifier) | |
# in the commit message. If this is found, `foo` will be extracted. | |
# The build-id can also be set by the workflow_dispatch trigger | |
# (i.e., running from the Github Actions UI). This will always override | |
# the build-id present in the commit message, if any. | |
id: extract | |
env: | |
message: ${{ github.event.head_commit.message }} | |
run: | | |
dest_tag=latest | |
build_id= | |
if [[ -n "${{ github.event.inputs.build-id }}" ]] | |
then | |
build_id="${{ github.event.inputs.build-id }}" | |
elif [[ "${{ github.ref }}" == "refs/heads/test-tag-latest-workflow" ]] | |
then | |
build_id="${{ github.actor }}-test" | |
dest_tag="${{ github.actor }}-latest" | |
elif echo "${{ env.message }}" | grep '(build-id:' | |
then | |
build_id="${message#*build-id:}" | |
build_id=$(echo "${build_id}" | head -n 1 | cut -f1 -d')' | sed 's| ||g') | |
else | |
echo "::error::No build ID could be discerned; expected to find this in: '${message}'" | |
exit 1 | |
fi | |
echo ::set-output name=build-id::${build_id} | |
echo ::notice::Build ID: ${build_id} | |
echo ::set-output name=dest-tag::${dest_tag} | |
echo ::notice::Destination tag: ${dest_tag} | |
update-latest-from-build-id: | |
needs: [configure] | |
# If a build-id was found in the commit message, we will re-tag any | |
# images that are tagged with this build-id as `latest` | |
if: needs.configure.outputs.build-id | |
env: | |
build_id: ${{ needs.configure.outputs.build-id }} | |
dest_tag: ${{ needs.configure.outputs.dest-tag }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
# Because the images are already build and tagged by | |
# another workflow, we can re-tag in parallel and | |
# use a matrixed build | |
matrix: | |
include: | |
- image: poetry | |
- image: uw-saml-poetry | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Docker Login | |
uses: docker/login-action@v1.14.1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
if docker pull ${{ env.source_image }} | |
then | |
docker tag ${{ env.source_image }} ${{ env.dest_image }} | |
docker push ${{ env.dest_image }} | |
echo ::notice::Pushed ${{ env.dest_image }} | |
else | |
echo "::error::${{ env.source_image }} not found; nothing to update." | |
fi | |
env: | |
dest_image: ghcr.io/uwit-iam/${{ matrix.image }}:${{ env.dest_tag }} | |
source_image: ghcr.io/uwit-iam/${{ matrix.image }}:${{ env.build_id }} |