Create Tag #5
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: Create Tag | |
env: | |
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }} | |
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | |
OPENSHIFT_NAMESPACE: ${{ secrets.OFM_NAMESPACE_NO_ENV }}-dev | |
REPO_NAME: 'ecc-ofm' | |
BRANCH: ${{ github.ref_name }} | |
APP_NAME_FRONTEND: 'frontend' | |
APP_NAME_BACKEND: 'backend' | |
on: | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version Number' | |
required: true | |
jobs: | |
openshift-ci-cd: | |
name: Tag Image | |
# ubuntu-20.04 can also be used. | |
runs-on: ubuntu-20.04 | |
environment: dev | |
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.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_FRONTEND }}:latest ${{ env.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_FRONTEND }}-${{ env.BRANCH }}:${{ github.event.inputs.version }} | |
oc tag ${{ env.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_BACKEND }}:latest ${{ env.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_BACKEND }}-${{ env.BRANCH }}:${{ github.event.inputs.version }} |