diff --git a/.github/workflows/on-pr-main.yml b/.github/workflows/on-pr-main.yml index 55c9c32..c6b9435 100644 --- a/.github/workflows/on-pr-main.yml +++ b/.github/workflows/on-pr-main.yml @@ -7,8 +7,9 @@ on: concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true + # PR open and close use the same group, allowing only one at a time + group: pr-${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true jobs: builds: @@ -34,7 +35,7 @@ jobs: - uses: bcgov-nr/action-builder-ghcr@v1.1.2 with: package: ${{ matrix.package }} - tag: ${{ github.event.number }} + tag: ${{ github.event.number }}, ${{ github.event.pull_request.head.sha }} tag_fallback: test token: ${{ secrets.GITHUB_TOKEN }} build_file: ${{ matrix.build_file }} diff --git a/.github/workflows/pr-close.yml b/.github/workflows/pr-close.yml new file mode 100644 index 0000000..eb61d37 --- /dev/null +++ b/.github/workflows/pr-close.yml @@ -0,0 +1,43 @@ +name: Pull Request Closed + +on: + pull_request: + types: + - closed + +concurrency: + # PR open and close use the same group, allowing only one at a time + group: pr-${{ 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 + 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 + helm uninstall nr-oracle-service-${{ 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 + permissions: + packages: write + strategy: + matrix: + package: [nr-oracle-service, nr-oracle-service-init] + steps: + - uses: shrink/actions-docker-registry-tag@v3 + with: + registry: ghcr.io + repository: ${{ github.repository }}/${{ matrix.package }} + target: ${{ github.event.number }} + tags: test