Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pr close workflow #225

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,43 @@ concurrency:
cancel-in-progress: true

jobs:
# This job is needed for FAM
setup:
name: Reset the deployment number
runs-on: ubuntu-22.04
outputs:
zone: ${{ steps.calculate.outputs.zone }}
steps:
- name: Calculate the deployment number
id: calculate
run: |
echo "zone=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT

# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
if: '!github.event.pull_request.head.repo.fork'
runs-on: ubuntu-22.04
needs: setup
env:
ZONE: ${{ needs.setup.outputs.zone }}
steps:
- name: Remove OpenShift artifacts
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ vars.OC_SERVER }}
oc project ${{ vars.OC_NAMESPACE }}

# Remove old build runs, build pods and deployment pods
oc delete all,pvc,secret,cm -l app=${{ github.event.repository.name }}-${{ github.event.number }}
oc delete all,pvc,secret,cm -l app=${{ github.event.repository.name }}-${{ env.ZONE }}

# If merged into main, then handle any image promotions
image-promotions:
name: Image Promotions
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-22.04
needs: setup
env:
ZONE: ${{ needs.setup.outputs.zone }}
strategy:
matrix:
package: [backend, frontend]
Expand All @@ -42,5 +60,5 @@ jobs:
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ github.event.number }}
target: ${{ env.ZONE }}
tags: test
Loading