Add quintals and ton aliases #3
Workflow file for this run
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: Dependabot auto-merge | |
on: pull_request_target | |
jobs: | |
dependabot: | |
runs-on: shopify-ubuntu-latest | |
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} | |
steps: | |
- name: Dependabot metadata | |
id: metadata | |
uses: dependabot/fetch-metadata@v1.6.0 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Waiting for CI to finish | |
id: check_ci_failure | |
continue-on-error: true | |
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.dependency-group == 'auto_merge' }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)) | |
} | |
const query = `query ($org: String!, $repo: String!, $pullRequestNumber: Int!) { | |
organization(login: $org) { | |
repository(name: $repo) { | |
pullRequest(number: $pullRequestNumber) { | |
commits(last: 1) { | |
nodes { | |
commit { | |
status { | |
state | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}`; | |
const variables = { | |
org: context.repo.owner, | |
repo: context.repo.repo, | |
pullRequestNumber: context.issue.number | |
} | |
// Try for 30 minutes | |
let attempts = 30 | |
let ci_state = false | |
for (let i = 1; i <= attempts; i++) { | |
console.log(`Sleeping for 60 seconds`) | |
await sleep(60000) | |
const result = await github.graphql(query, variables) | |
const state = result["organization"]["repository"]["pullRequest"]["commits"]["nodes"][0]["commit"]["status"]["state"] | |
console.log(`Status is ${state} after ${i} attempts`) | |
if (state === "SUCCESS") { | |
ci_state = true | |
console.log("Proceeding with workflow as CI succeed") | |
break | |
} | |
} | |
core.setOutput("ci_state", ci_state) | |
- name: Send Slack notification if auto-merge failed | |
if: ${{ steps.check_ci_failure.outputs.ci_state == 'false' }} | |
uses: ruby/action-slack@v3.0.0 | |
with: | |
payload: | | |
{ | |
"attachments": [{ | |
"text": "Auto-merge failed for pull request <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}> in repository ${{ github.repository }}", | |
"color": "danger" | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.METRICS_SLACK_WEBHOOK_URL }} | |
- name: Approve and merge | |
if: ${{ steps.check_ci_failure.outputs.ci_state == 'true' && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.dependency-group == 'auto_merge') }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
await github.rest.pulls.createReview({ | |
pull_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
event: 'APPROVE', | |
}) | |
await github.rest.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) |