fix(ci): init cleanup and job consolidation #137
Workflow file for this run
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: Pull Request Close | |
on: | |
pull_request: | |
types: | |
- closed | |
env: | |
REGISTRY: ghcr.io | |
NAME: ${{ github.event.repository.name }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number }} | |
cancel-in-progress: true | |
jobs: | |
# Clean up OpenShift when PR closed, no conditions | |
cleanup-openshift: | |
name: Cleanup OpenShift | |
runs-on: ubuntu-22.04 | |
environment: | |
name: dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Remove OpenShift artifacts | |
run: | | |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }} | |
oc project ${{ secrets.OC_NAMESPACE }} | |
# Remove old build runs, build pods and deployment pods | |
oc delete all,pvc,secret -l app=${{ env.NAME }}-${{ github.event.number }} | |
# 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 | |
steps: | |
- name: Promoting API | |
uses: shrink/actions-docker-registry-tag@v3 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/api | |
target: ${{ github.event.number }} | |
tags: test | |
# Notify when PR merged and branch = main | |
merge-notification: | |
name: Merge Notification | |
runs-on: ubuntu-22.04 | |
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | |
steps: | |
- name: Pre-merge update | |
uses: mshick/add-pr-comment@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
allow-repeats: false | |
message: | | |
Your Pull Request code is being promoted! Please follow the link below. | |
[Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml) |