-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 2.1 KB
/
create-git-and-image-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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-24.04
environment: dev
steps:
- name: Print Workflow Dispatch Inputs and Env Vars
uses: shayki5/print-workflow-dispatch-inputs@v1
with:
add_to_summary: 'true'
print_env_vars: 'false'
- 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.16
# 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.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_FRONTEND }}:latest ${{ env.OPENSHIFT_NAMESPACE }}/${{ env.REPO_NAME }}-${{ env.APP_NAME_FRONTEND }}:${{ 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 }}:${{ github.event.inputs.version }}