Skip to content

Commit f285c93

Browse files
committed
ci: add deployment when merging to main
1 parent 0293fb9 commit f285c93

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/package.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,34 @@ jobs:
4343
push: true
4444
tags: ${{ steps.meta.outputs.tags }}
4545
labels: ${{ steps.meta.outputs.labels }}
46+
deploy:
47+
runs-on: ubuntu-22.04
48+
if: ${{ github.ref_type != 'tag' }}
49+
needs:
50+
- package
51+
env:
52+
RUN_REPOSITORY_NAME: "polyflix/infrastructure"
53+
WORKFLOW_ID: 45367438
54+
GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
55+
steps:
56+
- uses: actions/checkout@v3
57+
- name: trigger infrastructure workflow
58+
run: |
59+
export SHA_SHORT=`git rev-parse --short HEAD`
60+
export SHA_SHORT="sha-${SHA_SHORT}"
61+
# Fetch the repository name (e.g video)
62+
export REPO_NAME=`gh api /repos/${{github.repository }} --jq .name`
63+
64+
echo "Image tag: ${SHA_SHORT}"
65+
echo "Repository name: ${REPO_NAME}"
66+
67+
# Run the workflow to deploy the current version
68+
# We don't use `gh workflow` command because fine-grained PAT is not yet
69+
# available for this command, so we need to call directly the API
70+
gh api /repos/${RUN_REPOSITORY_NAME}/actions/workflows/${WORKFLOW_ID}/dispatches \
71+
-X POST \
72+
-F "inputs[environment]=qa" \
73+
-F "inputs[service]=${REPO_NAME}" \
74+
-F "inputs[options]=--set image.tag=${SHA_SHORT}" \
75+
-F ref=main
76+

0 commit comments

Comments
 (0)