Skip to content

Commit 61ba5ff

Browse files
authored
DX-3099 Update actions/checkout and actions/setup-* (#146)
Also migrated to github-script for PR comment
1 parent ffef6a7 commit 61ba5ff

File tree

3 files changed

+35
-50
lines changed

3 files changed

+35
-50
lines changed

.github/actions/add_pr_comment/action.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
fi
9696
9797
- name: Checkout
98-
uses: actions/checkout@v2
98+
uses: actions/checkout@v3
9999

100100
- name: Install Packages
101101
run: pip install -r requirements_dev.txt

.github/workflows/listener.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
# Ingest repository_dispatch events and trigger appropriate actions
1+
# Ingest repository_dispatch events and trigger appropriate actions
22
name: Listener
33

44
on:
55
repository_dispatch:
66
types: [Build]
77

88
jobs:
9-
build:
9+
build:
1010
if: ${{ github.event.action == 'Build' }}
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
1414

15-
- name: Build SDK and Open PR
15+
- name: Build SDK and Open PR
1616
uses: Bandwidth/[email protected]
17-
with:
17+
with:
1818
branch-name: ${{ github.event.client_payload.branchName }}
1919
username: ${{ secrets.DX_GITHUB_USERNAME }}
2020
token: ${{ secrets.DX_GITHUB_TOKEN }}
2121
openapi-generator-version: v5.4.0
22-
language: python
22+
language: python
2323
config: ./openapi-config.yml
24-
env:
24+
env:
2525
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
26-
26+
2727
- name: Open Pull Request
2828
run: |
2929
exists=$(hub pr list -h {{ inputs.branch-name }})
@@ -34,18 +34,34 @@ jobs:
3434
echo "PR already exists for this branch"
3535
fi
3636
env:
37-
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
38-
39-
- name: Output PR Number
37+
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
38+
39+
- name: Output PR Number
4040
id: output-pr-number
4141
run: echo "PR_NUMBER=$(hub pr list -h ${{ inputs.branch-name }} -f %I)" >> $GITHUB_ENV
4242
env:
43-
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
43+
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
4444

45-
- uses: ./.github/actions/add_pr_comment
46-
with:
47-
username: ${{ secrets.DX_GITHUB_USERNAME }}
48-
token: ${{ secrets.DX_GITHUB_TOKEN }}
49-
repo-name: api-specs
50-
pr-number: ${{ github.event.client_payload.prNumber }}
51-
message: 'Python SDK built successfully\n\nSee the corresponding PR opened on the SDK repository (no action required):\nhttps://github.com/Bandwidth/api-docs/pull/${{ env.PR_NUMBER }}'
45+
- uses: actions/github-script@v6
46+
with:
47+
github-token: ${{secrets.DX_GITHUB_TOKEN}}
48+
script: |
49+
github.rest.issues.createComment({
50+
issue_number: ${{ github.event.client_payload.prNumber }},
51+
owner: context.repo.owner,
52+
repo: 'api-specs',
53+
body: 'Python SDK built successfully\n\nSee the corresponding PR opened on the SDK repository (no action required):\nhttps://github.com/Bandwidth/api-docs/pull/${{ env.PR_NUMBER }}'
54+
})
55+
56+
- name: Notify for Failure
57+
uses: actions/github-script@v6
58+
if: failure()
59+
with:
60+
github-token: ${{secrets.DX_GITHUB_TOKEN}}
61+
script: |
62+
github.rest.issues.createComment({
63+
issue_number: ${{ github.event.client_payload.prNumber }},
64+
owner: context.repo.owner,
65+
repo: 'api-specs',
66+
body: 'Python SDK failed to build successfully\n\nSee the Python SDK repository [action logs](https://github.com/Bandwidth/python-sdk/actions) for more information.'
67+
})

0 commit comments

Comments
 (0)