Skip to content

Commit

Permalink
ci: add deployment when merging to main
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebrg committed Jan 13, 2023
1 parent 0293fb9 commit f285c93
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,34 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-22.04
if: ${{ github.ref_type != 'tag' }}
needs:
- package
env:
RUN_REPOSITORY_NAME: "polyflix/infrastructure"
WORKFLOW_ID: 45367438
GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: trigger infrastructure workflow
run: |
export SHA_SHORT=`git rev-parse --short HEAD`
export SHA_SHORT="sha-${SHA_SHORT}"
# Fetch the repository name (e.g video)
export REPO_NAME=`gh api /repos/${{github.repository }} --jq .name`
echo "Image tag: ${SHA_SHORT}"
echo "Repository name: ${REPO_NAME}"
# Run the workflow to deploy the current version
# We don't use `gh workflow` command because fine-grained PAT is not yet
# available for this command, so we need to call directly the API
gh api /repos/${RUN_REPOSITORY_NAME}/actions/workflows/${WORKFLOW_ID}/dispatches \
-X POST \
-F "inputs[environment]=qa" \
-F "inputs[service]=${REPO_NAME}" \
-F "inputs[options]=--set image.tag=${SHA_SHORT}" \
-F ref=main

0 comments on commit f285c93

Please sign in to comment.