Create Tag #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: Create Tag | |
env: | |
# 🖊️ EDIT your repository secrets to log into your OpenShift cluster and set up the context. | |
# See https://github.com/redhat-actions/oc-login#readme for how to retrieve these values. | |
# To get a permanent token, refer to https://github.com/redhat-actions/oc-login/wiki/Using-a-Service-Account-for-GitHub-Actions | |
OPENSHIFT_SERVER: ${{ vars.OPENSHIFT_SERVER }} | |
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | |
OPENSHIFT_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}-dev | |
# 🖊️ EDIT to specify custom tags for the container image, or default tags will be generated below. | |
IMAGE_TAGS: "" | |
REPO_NAME: "educ-grad-trax-api" | |
BRANCH: "master" | |
NAMESPACE: ${{ vars.GRAD_NAMESPACE }} | |
on: | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version Number' | |
required: true | |
jobs: | |
tag_image: | |
name: Tag Image | |
runs-on: ubuntu-20.04 | |
environment: dev | |
outputs: | |
ROUTE: ${{ steps.deploy-and-expose.outputs.route }} | |
SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Create tag | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ github.event.inputs.version }}', | |
sha: context.sha | |
}) | |
- name: Install oc | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
oc: 4 | |
# https://github.com/redhat-actions/oc-login#readme | |
- uses: actions/checkout@v2 | |
- name: Tag in OpenShift | |
run: | | |
set -eux | |
# Login to OpenShift and select project | |
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} | |
oc project ${{ env.OPENSHIFT_NAMESPACE }} | |
oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}:latest ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}:${{ github.event.inputs.version }} |