Skip to content

Commit

Permalink
create tag
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunlumbcgov committed Sep 28, 2023
1 parent 86a3daa commit 966ce60
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/tag-create.git.and.imagestream.tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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: ${{ secrets.OPENSHIFT_SERVER }}
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
OPENSHIFT_NAMESPACE: ${{ secrets.SDCI_NAMESPACE_NO_ENV }}-dev

REPO_NAME: "educ-sdci"
BRANCH: "main"
NAMESPACE: ${{ secrets.SDCI_NAMESPACE_NO_ENV }}

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-latest can also be used.
runs-on: ubuntu-22.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@v3

- name: Create tag
uses: actions/github-script@v6
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@v3
- 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 }}-frontend-static:latest ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-frontend-static:${{ github.event.inputs.version }}
oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:latest ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:${{ github.event.inputs.version }}

0 comments on commit 966ce60

Please sign in to comment.