Webhook Update staging #522
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: Webhook Update staging | |
on: | |
workflow_run: | |
workflows: ["Docker Image CI"] | |
types: | |
- completed | |
jobs: | |
webhook: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Wait for Docker workflow to complete | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
const runs = await github.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'docker.yml', | |
status: 'completed', | |
per_page: 1 | |
}); | |
const completedRun = runs.data.workflow_runs[0]; | |
if (!completedRun || completedRun.conclusion !== 'success') { | |
throw new Error('Docker workflow failed or not completed successfully.'); | |
} | |
console.log('Docker workflow completed successfully. Proceed with webhook.'); | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger second repository | |
run: | | |
curl -XPOST -u "eolito:${{secrets.WEBHOOK_SECRET}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eol-uchile/edx-kustomize/dispatches --data '{"event_type": "update-images", "client_payload": {"type": "staging"}}' |