Skip to content

Commit

Permalink
updated failed preview deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tellmeY18 committed Jan 10, 2025
1 parent 86eba9b commit 42b2db0
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions .github/workflows/label-deploy-failed.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
name: Auto label failed preview deploys

name: Auto label deploy preview status
permissions:
pull-requests: write
issues: write

on:
issue_comment:
types:
- created
- edited
types: [created, edited]

jobs:
auto-label-deploy-failed:
manage-deploy-labels:
runs-on: ubuntu-latest
if: |
github.repository == 'ohcnetwork/care_fe' && github.event.issue.pull_request &&
github.repository == 'ohcnetwork/care_fe' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, 'Deploy Preview')
steps:
- name: Add 'Deploy-Failed'
if: contains(github.event.comment.body, 'failed')
- name: Check out the repository
uses: actions/checkout@v3

- name: Check deploy status
id: check-status
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["Deploy-Failed"]
})
const comment = context.payload.comment.body;
return {
isDeployFailed: /deploy preview.*failed|failed to deploy/i.test(comment),
isDeploySuccessful: /deploy preview.*ready|successfully deployed/i.test(comment),
};
- name: Remove 'Deploy-Failed' label
if: contains(github.event.comment.body, 'ready')
uses: actions/github-script@v6
- name: Add Deploy-Failed label if needed
if: steps.check-status.outputs.isDeployFailed == 'true'
uses: actions/labeler@v5
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["Deploy-Failed"]
})
repo-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Remove Deploy-Failed label if deploy is successful
if: steps.check-status.outputs.isDeploySuccessful == 'true'
run: |
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/Deploy-Failed

0 comments on commit 42b2db0

Please sign in to comment.