Skip to content

Commit

Permalink
#1719 Create Release Strategy (#1814)
Browse files Browse the repository at this point in the history
#1719 Create Release Strategy (#1814)
  • Loading branch information
ann-aot authored Mar 17, 2023
1 parent c984117 commit 8a4f5e7
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 201 deletions.
95 changes: 86 additions & 9 deletions .github/workflows/build-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,120 @@ on:
types: [opened, reopened, synchronize, closed]
branches:
- main
workflow_dispatch:
inputs:
bumb:
description: "Select the version."
required: false
default: "prerelease"
type: choice
options:
- prerelease
- major
- premajor
- minor
- preminor
- patch
- prepatch
releaseType:
description: "Select the release type. By default, only a tag will be created. If you want to create a release with the tag select the type."
type: choice
required: false
options:
-
- draft
- publish

jobs:
# Print variables for logging and debugging purposes
checkEnv:
name: Check Env variables
environment: DEV
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == true}}
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
steps:
- name: Print Env Vars
run: |
echo Git Base Ref: ${{ github.base_ref }}
echo Git Build ID: ${{ github.event.number }}
echo Git Pull Request Ref: ${{ github.event.pull_request.head.sha }}
echo OC CLI Version: $(oc version)
# Create new tag.
createTag:
name: "Create tag"
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Get bumb value
uses: haya14busa/action-cond@v1
id: getBumb
with:
cond: ${{ github.event_name == 'workflow_dispatch'}}
if_true: ${{ inputs.bumb }}
if_false: 'prerelease'

- name: Get preId value, if provided
uses: haya14busa/action-cond@v1
id: getPreId
with:
cond: ${{ github.event_name == 'workflow_dispatch' && (inputs.bumb == 'premajor' || inputs.bumb == 'preminor' || inputs.bumb == 'prepatch' || inputs.bumb == 'prerelease') }}
if_true: ${{ inputs.bumb }}
if_false: 'prerelease'
- run: |
echo "bumb: ${{ steps.getBumb.outputs.value }}"
echo "preId: ${{ steps.getPreId.outputs.value }}"
- id: createNextTag
name: "Create tag"
uses: zwaldowski/semver-release-action@v3
with:
prefix: "v"
preid: ${{ steps.getPreId.outputs.value }}
bump: ${{ steps.getBumb.outputs.value }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: echo "Tag ${{ steps.createNextTag.outputs.version_tag }} created!"
outputs:
newTag: ${{ steps.createNextTag.outputs.version_tag }}

# Create new release.
createRelease:
name: "Create release"
if: github.event_name == 'workflow_dispatch' && (inputs.releaseType == 'publish' || inputs.releaseType == 'draft')
runs-on: ubuntu-latest
needs: createTag
steps:
- name: Create release
id: createNewRelease
uses: Roang-zero1/github-create-release-action@v3
with:
created_tag: ${{ needs.createTag.outputs.newTag }}
create_draft: ${{ inputs.releaseType == 'draft' }}
release_title: Release ${{ needs.createTag.outputs.newTag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "created release ${{ needs.createTag.outputs.newTag }} ${{ steps.createNewRelease.outputs.html_url }}!"

# Building all packages
build:
name: Building all packages
environment: DEV
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == true}}
needs: createTag
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
env:
BUILD_ID: ${{ github.event.number }}
BUILD_NAMESPACE: 0c27fb-tools
BUILD_REF: ${{ github.base_ref }}
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
HOST_PREFIX: ${{ secrets.HOST_PREFIX }}
steps:
# Checkout the PR branch
- name: Print env
run: |
echo BUILD ID: $BUILD_ID
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: $BUILD_REF
- name: Checkout Target Branch
uses: actions/checkout@v3
with:
ref: $BUILD_REF
# Log in to OpenShift.
# Note: The secrets needed to log in are NOT available if the PR comes from a FORK.
# PR's must originate from a branch off the original repo or else all openshift `oc` commands will fail.
Expand Down Expand Up @@ -72,10 +150,10 @@ jobs:
environment: DEV
needs:
- build
- createTag
env:
BUILD_ID: ${{ github.event.number }}
NAMESPACE: ${{ secrets.OPENSHIFT_ENV_NAMESPACE }}
BUILD_REF: ${{ github.base_ref }}
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
HOST_PREFIX: ${{ secrets.HOST_PREFIX }}
BUILD_NAMESPACE: 0c27fb-tools
KEYCLOAK_REALM: "aestsims"
Expand Down Expand Up @@ -104,7 +182,6 @@ jobs:
steps:
- name: Print env
run: |
echo BUILD ID: $BUILD_ID
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo NAMESPACE: $NAMESPACE
echo BRANCH: $BUILD_REF
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-deploy-forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
env:
FORMIO_SOURCE_REPO_TAG: ${{ github.event.inputs.formioTag }}
FORMS_NAME: forms
BUILD_ID: ${{ github.event.inputs.buildId }}
NAMESPACE: ${{ secrets.OPENSHIFT_ENV_NAMESPACE }}
BUILD_REF: ${{ github.event.inputs.buildRef }}
HOST_PREFIX: ${{ secrets.HOST_PREFIX }}
Expand All @@ -30,7 +29,6 @@ jobs:
steps:
- name: Print env
run: |
echo BUILD ID: $BUILD_ID
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo NAMESPACE: $NAMESPACE
echo BRANCH: $BUILD_REF
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/deploy-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
description: "Build Ref"
required: true
default: "main"
buildId:
description: "Build Id"
required: true
default: "NULL"
environment:
required: true
type: environment
Expand All @@ -27,9 +23,6 @@ on:
buildRef:
required: true
type: string
buildId:
required: true
type: string
environment:
required: true
type: string
Expand All @@ -46,7 +39,6 @@ jobs:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
env:
BUILD_ID: ${{ github.event.inputs.buildId }}
NAMESPACE: ${{ secrets.OPENSHIFT_ENV_NAMESPACE }}
BUILD_REF: ${{ github.event.inputs.buildRef }}
HOST_PREFIX: ${{ secrets.HOST_PREFIX }}
Expand All @@ -72,7 +64,6 @@ jobs:
steps:
- name: Print env
run: |
echo BUILD ID: $BUILD_ID
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo NAMESPACE: $NAMESPACE
echo BRANCH: $BUILD_REF
Expand Down Expand Up @@ -114,6 +105,7 @@ jobs:
uses: ./.github/workflows/deploy-camunda-definitions.yml
with:
environment: ${{ github.event.inputs.environment }}
gitRef: ${{ github.event.inputs.buildRef }}
secrets: inherit
deployFormioDefinitions:
if: ${{ github.event.inputs.deployFormioDefinitions == 'true' }}
Expand All @@ -123,4 +115,5 @@ jobs:
uses: ./.github/workflows/deploy-formio-definitions.yml
with:
environment: ${{ github.event.inputs.environment }}
gitRef: ${{ github.event.inputs.buildRef }}
secrets: inherit
8 changes: 8 additions & 0 deletions .github/workflows/deploy-camunda-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ on:
environment:
required: true
type: environment
gitRef:
required: true
type: string
workflow_call:
inputs:
environment:
required: true
type: string
gitRef:
required: true
type: string

jobs:
deploy:
Expand All @@ -29,6 +35,8 @@ jobs:
echo RESOURCES_FOLDER: $RESOURCES_FOLDER
- name: Checkout Target Branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.gitRef }}
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/deploy-formio-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ on:
environment:
required: true
type: environment
gitRef:
required: true
type: string
workflow_call:
inputs:
environment:
required: true
type: string
gitRef:
required: true
type: string

jobs:
deploy:
Expand All @@ -24,6 +30,8 @@ jobs:
steps:
- name: Checkout Target Branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.gitRef }}
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
Expand Down
Loading

0 comments on commit 8a4f5e7

Please sign in to comment.