-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (82 loc) · 3.19 KB
/
issue_comment.yml
File metadata and controls
89 lines (82 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: ghstack land
on:
issue_comment:
types: [created]
jobs:
ghstack_land:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/land') }}
runs-on: ubuntu-latest
steps:
- name: Show Environment Variables
run: env
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Add reaction to comment
run: |
COMMENT_ID=$(echo "${{ github.event.comment.id }}")
REPO="${{ github.repository }}"
curl -X POST \
-H "Authorization: token ${{ steps.app-token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/issues/comments/$COMMENT_ID/reactions" \
-d '{"content":"rocket"}'
- name: Show Github Object
run: |
cat <<'EOF'
${{ toJson(github) }}
EOF
- name: Show Github Event Path Json
run: 'cat $GITHUB_EVENT_PATH || true'
- name: Get PR details
id: get-pr
run: |
PR_NUMBER=${{ github.event.issue.number }}
echo "PR number is $PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
# Get PR details using GitHub API
PR_DATA=$(curl -s \
-H "Authorization: token ${{ steps.app-token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
"${{ github.api_url }}/repos/${{ github.repository }}/pulls/$PR_NUMBER")
# Extract useful information
PR_HEAD_REF=$(echo "$PR_DATA" | jq -r .head.ref)
PR_HEAD_SHA=$(echo "$PR_DATA" | jq -r .head.sha)
PR_URL="${{ github.server_url }}/${{ github.repository }}/pull/$PR_NUMBER"
echo "pr_branch=$PR_HEAD_REF" >> $GITHUB_OUTPUT
echo "pr_sha=$PR_HEAD_SHA" >> $GITHUB_OUTPUT
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
echo "pr_branch=$PR_HEAD_REF"
echo "pr_sha=$PR_HEAD_SHA"
echo "pr_url=$PR_URL"
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: '0'
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Check Current CI Status
run: |
pip install requests ghstack
echo ${{ github.event.issue.number }}
.github/workflows/scripts/ghstack-perm-check.py ${{ github.event.issue.number }} ${{steps.get-pr.outputs.pr_branch}} ${{ github.repository }}
EOF
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Land It!
run: |
git config --global user.email "bot@thinkingmachines.ai"
git config --global user.name "ghstack bot"
cat <<EOF > ~/.ghstackrc
[ghstack]
github_url = github.com
github_oauth = $GITHUB_TOKEN
github_username = foo
remote_name = origin
EOF
ghstack land "${{ steps.get-pr.outputs.pr_url }}"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}