Creating new tag in quay based on pushed tag in Github. #12
Workflow file for this run
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: Image push per Github Tag | |
# This GitHub action activates whenever a new tag is created on the repo under "opendatahub-io" | |
# and creates a copy of the image of the associated commit hash with the | |
# appropriate tag name. | |
run-name: Creating new tag in quay based on pushed tag in Github. | |
on: | |
push: | |
tags: | |
- '*' | |
env: | |
QUAY_IMAGE_REPO: ${{ secrets.QUAY_IMAGE_REPO }} | |
jobs: | |
copy-tag-to-quay: | |
runs-on: ubuntu-latest | |
if: github.repository == 'opendatahub-io/data-science-pipelines-operator' | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Install skopeo | |
shell: bash | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install skopeo | |
- name: Login to quay.io | |
shell: bash | |
env: | |
QUAY_ROBOT_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }} | |
QUAY_ROBOT_TOKEN: ${{ secrets.QUAY_ROBOT_TOKEN }} | |
run: | | |
skopeo login quay.io -u ${QUAY_ROBOT_USERNAME} -p ${QUAY_ROBOT_TOKEN} | |
- name: Get latest tag name | |
id: tag | |
run: echo "tag=$(git describe --tags --abbrev=0)" >> ${GITHUB_OUTPUT} | |
- name: Get latest tag hash | |
id: hash | |
run: echo "hash=$(git rev-parse --short ${{ steps.tag.outputs.tag }} )" >> ${GITHUB_OUTPUT} | |
- name: Create new tag | |
shell: bash | |
env: | |
TAG: ${{ steps.tag.outputs.tag }} | |
HASH: ${{ steps.hash.outputs.hash }} | |
run: | | |
skopeo copy docker://${QUAY_IMAGE_REPO}:main-${{ env.HASH }} docker://${QUAY_IMAGE_REPO}:${{ env.TAG }} | |
- name: Create latest tag | |
shell: bash | |
env: | |
HASH: ${{ steps.hash.outputs.hash }} | |
run: | | |
skopeo copy docker://${QUAY_IMAGE_REPO}:main-${{ env.HASH }} docker://${QUAY_IMAGE_REPO}:latest |