Merge to Main #20
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: Merge to Main | |
on: | |
workflow_run: | |
workflows: [Pull Request Closed] | |
types: [completed] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
codeql: | |
name: Semantic Code Analysis | |
runs-on: ubuntu-22.04 | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: javascript | |
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | |
# If this step fails, then you should remove it and run the build manually (see below) | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v3 | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
semantic-version: | |
outputs: | |
semanticVersion: ${{ steps.changelog.outputs.version }} | |
tag: ${{ steps.changelog.outputs.tag }} | |
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }} | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Conventional Changelog Update | |
uses: TriPSs/[email protected] | |
id: changelog | |
with: | |
github-token: ${{ github.token }} | |
output-file: 'CHANGELOG.md' | |
skip-version-file: 'true' | |
skip-commit: 'true' | |
skip-on-empty: 'false' | |
git-push: 'true' | |
retag-images: | |
needs: [ semantic-version ] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
package: [ api, database, frontend ] | |
steps: | |
- name: Tag Docker Images | |
uses: shrink/actions-docker-registry-tag@v4 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/${{ matrix.package }} | |
target: test | |
tags: ${{ needs.semantic-version.outputs.semanticVersion }} | |
deploys: | |
name: TEST Deployments | |
needs: [retag-images, semantic-version] | |
environment: test | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy | |
shell: bash | |
run: | | |
# Allow pipefail, since we could be catching oc create errors | |
set +o pipefail | |
# Login to OpenShift (NOTE: project command is a safeguard) | |
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} | |
oc project ${{ vars.oc_namespace }} | |
cd charts/pubcode | |
# Deploy Helm Chart | |
helm dependency update | |
helm upgrade --install --wait --atomic pubcode-test --values values.yaml --set-string global.repository=${{ github.repository }} --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.semanticVersion }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.semanticVersion }}" --set-string global.secrets.emailRecipients="${{ secrets.EMAIL_RECIPIENTS }}" --set-string global.secrets.chesTokenURL="${{ secrets.CHES_TOKEN_URL }}" --set-string global.secrets.chesClientID="${{ secrets.CHES_CLIENT_ID }}" --set-string global.secrets.chesClientSecret="${{ secrets.CHES_CLIENT_SECRET }}" --set-string global.secrets.chesAPIURL="${{ secrets.CHES_API_URL }}" --set-string global.secrets.databaseAdminPassword="${{ secrets.DB_PWD }}" --set-string namespace="${{ vars.oc_namespace }}" --timeout 5m . | |
tests: | |
name: Tests | |
needs: [deploys] | |
uses: ./.github/workflows/.tests.yml | |
with: | |
target: test | |
deploys-prod: | |
name: PROD Deployments | |
needs: [semantic-version, tests] | |
environment: prod | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy | |
shell: bash | |
run: | | |
# Allow pipefail, since we could be catching oc create errors | |
set +o pipefail | |
# Login to OpenShift (NOTE: project command is a safeguard) | |
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} | |
oc project ${{ vars.oc_namespace }} | |
# Deploy Helm Chart | |
cd charts/pubcode | |
helm dependency update | |
helm upgrade --install --wait --atomic pubcode --values values.yaml --set-string global.repository=${{ github.repository }} --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.semanticVersion }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.semanticVersion }}" --set-string global.secrets.emailRecipients="${{ secrets.EMAIL_RECIPIENTS }}" --set-string global.secrets.chesTokenURL="${{ secrets.CHES_TOKEN_URL }}" --set-string global.secrets.chesClientID="${{ secrets.CHES_CLIENT_ID }}" --set-string global.secrets.chesClientSecret="${{ secrets.CHES_CLIENT_SECRET }}" --set-string global.secrets.chesAPIURL="${{ secrets.CHES_API_URL }}" --set-string global.secrets.databaseAdminPassword="${{ secrets.DB_PWD }}" --set-string namespace="${{ vars.oc_namespace }}" --timeout 5m . | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
token: ${{ github.token }} | |
tag_name: ${{ needs.semantic-version.outputs.tag }} | |
name: ${{ needs.semantic-version.outputs.tag }} | |
body: ${{ needs.semantic-version.outputs.clean_changelog }} |