Skip to content

Commit

Permalink
Start using deploy tag param
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Nov 21, 2023
1 parent f5addf1 commit 93773ff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ on:
required: false
type: string

env:
release: ${{ github.event.repository.name }}-${{ inputs.target }}
tag: ${{ inputs.tag }}

jobs:
deploys:
name: Helm
Expand Down Expand Up @@ -92,11 +96,11 @@ jobs:
oc project ${{ vars.OC_NAMESPACE }} # Safeguard!
# Interrupt any previous jobs (status = pending-upgrade)
PREVIOUS=$(helm status ${{ github.event.repository.name }}-${{ inputs.target }} -o json | jq .info.status || true)
PREVIOUS=$(helm status ${{ env.release }} -o json | jq .info.status || true)
if [[ ${PREVIOUS} =~ pending ]]; then
echo "Rollback triggered"
helm rollback ${{ github.event.repository.name }}-${{ inputs.target }} || \
helm uninstall ${{ github.event.repository.name }}-${{ inputs.target }}
helm rollback ${{ env.release }} || \
helm uninstall ${{ env.release }}
fi
# Deploy Helm Chart
Expand All @@ -105,11 +109,10 @@ jobs:
--set global.autoscaling=${{ inputs.autoscaling }} \
--set-string global.repository=${{ github.repository }} \
--set-string global.secrets.databasePassword=${{ secrets.DB_PASSWORD }} \
--set-string global.tag="${{ inputs.target }}" \
--set-string backend.containers[0].tag="${{ inputs.target }}" \
--set-string backend.initContainers[0].tag="${{ inputs.target }}" \
--set-string frontend.containers[0].tag="${{ inputs.target }}" \
--install --wait --atomic ${{ github.event.repository.name }}-${{ inputs.target }} \
--set-string backend.containers[0].tag="${{ env.tag }}" \
--set-string backend.initContainers[0].tag="${{ env.tag }}" \
--set-string frontend.containers[0].tag="${{ env.tag }}" \
--install --wait --atomic ${{ env.release }} \
--timeout ${{ inputs.timeout-minutes }}m \
--values ${{ inputs.values }} .
Expand Down
27 changes: 15 additions & 12 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Merge

on:
workflow_run:
workflows: [PR Closed]
types: [completed]
workflow_dispatch:
push: [${{ github.event.repository.default_branch }}]

env:
pr: ${{ github.event.number }}

jobs:
semver:
name: Semantic Version
outputs:
tag: ${{ steps.semver.outputs.tag }}
semver: ${{ steps.tag.outputs.semver }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
Expand All @@ -19,8 +19,9 @@ jobs:
ref: ${{ github.event.repository.default_branch }}

- name: Conventional Changelog Update
# Outputs semver as steps.id.outputs.tag
uses: TriPSs/conventional-changelog-action@v4
id: semver
id: changelog
with:
git-branch: refs/heads/${{ github.event.repository.default_branch }}
git-push: "false"
Expand All @@ -31,20 +32,22 @@ jobs:

- name: Create Tags
if: ${{ steps.semver.outputs.tag != '' }}
id: tag
# Create tag and output semver
run: |
git tag ${{ steps.changelog.outputs.tag }}
git push origin --tag
echo "semver=${{ steps.semver.outputs.tag }}" >> $GITHUB_OUTPUT
deploy-test:
name: Deploy (test)
if: ${{ needs.semver.outputs.tag != '' }}
if: ${{ needs.semver.outputs.semver != '' }}
needs: [semver]
uses: ./.github/workflows/.deploy.yml
secrets: inherit
with:
environment: test
tag: test
target: test
target: ${{ env.tag }}

integration-e2e:
name: Integration and E2E Tests
Expand All @@ -60,11 +63,11 @@ jobs:
secrets: inherit
with:
environment: prod
tag: test
tag: ${{ env.tag }}
target: prod

promote-prod:
name: Tag Images
name: Promote Images
needs: [deploy-prod]
runs-on: ubuntu-22.04
permissions:
Expand All @@ -78,5 +81,5 @@ jobs:
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: test
target: ${{ env.tag }}
tags: prod
1 change: 1 addition & 0 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ jobs:
secrets: inherit
with:
autoscaling: false
tag: ${{ github.event.number }}
target: ${{ github.event.number }}
triggers: ('backend/' 'frontend/' 'migrations/' 'charts/')

0 comments on commit 93773ff

Please sign in to comment.