Skip to content

Commit

Permalink
ci: 💚 fix app preview re-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-tobi committed Oct 8, 2024
1 parent 0e2b292 commit da24ddd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ on:
USE_QEMU:
required: true
type: boolean
PR_NUMBER:
required: false
type: number
workflow_dispatch:
inputs:
REGISTRY:
Expand All @@ -49,6 +52,10 @@ on:
required: true
type: boolean
default: false
PR_NUMBER:
description: ID number of the pull request to use for deploy preview app
required: false
type: number

jobs:
matrix:
Expand Down Expand Up @@ -201,20 +208,19 @@ jobs:
docker buildx imagetools inspect ${{ inputs.REGISTRY }}/${{ inputs.NAMESPACE }}/${{ matrix.images.name }}:${{ steps.meta.outputs.version }}
preview:
needs:
- merge
name: Redeploy preview app
if: contains(github.event.pull_request.labels.*.name, 'preview')
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview') && inputs.PR_NUMBER != '' }}
runs-on: ubuntu-latest
steps:
- name: Replace template fields
id: feed-template
run: |
echo "ARGOCD_SYNC_PAYLOAD=$(echo "${{ vars.ARGOCD_SYNC_PAYLOAD_TEMPLATE }}" | sed 's|<pr_number>|${{ github.event.number }}|g')" >> $GITHUB_OUTPUT
echo "ARGOCD_APP_NAME=$(echo '${{ vars.ARGOCD_APP_NAME_TEMPLATE }}' | sed 's|<pr_number>|${{ github.event.pull_request.number || inputs.PR_NUMBER }}|g')" >> $GITHUB_OUTPUT
echo "ARGOCD_SYNC_PAYLOAD=$(echo '${{ vars.ARGOCD_SYNC_PAYLOAD_TEMPLATE }}' | sed 's|<pr_number>|${{ github.event.pull_request.number || inputs.PR_NUMBER }}|g')" >> $GITHUB_OUTPUT
- name: Deploy new image
run: |
curl -X POST ${{ vars.ARGOCD_URL }}/api/v1/applications/cloud-pi-native-docs/sync \
curl -X POST ${{ vars.ARGOCD_URL }}/api/v1/applications/${{ steps.feed-template.outputs.ARGOCD_APP_NAME }} }}/sync \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.ARGOCD_TOKEN }}" \
-d '${{ steps.feed-template.outputs.ARGOCD_SYNC_PAYLOAD }}'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
TAG: pr-${{ github.event.pull_request.number || github.event.number }}
MULTI_ARCH: ${{ needs.expose-vars.outputs.MULTI_ARCH == 'true' }}
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.number }}

build-label:
uses: ./.github/workflows/label.yml
Expand Down

0 comments on commit da24ddd

Please sign in to comment.