@@ -7,12 +7,18 @@ inputs:
77 image :
88 required : true
99 description : " Which image to deploy"
10- token :
10+ version :
11+ required : true
12+ description : " Which version to deploy"
13+ fly_token :
1114 required : true
1215 description : " Access token for flyctl"
1316 slack_webhook_url :
1417 required : true
1518 description : " Webhook URL for slack"
19+ gh_token :
20+ description : ' The GitHub token to use for the API requests'
21+ required : true
1622
1723runs :
1824 using : ' composite'
@@ -42,11 +48,63 @@ runs:
4248 --workdir /workspace \
4349 ghcr.io/superfly/flyctl:latest \
4450 deploy \
45- -t ${{ inputs.token }} \
51+ -t ${{ inputs.fly_token }} \
4652 -c /workspace/fly.toml \
4753 -i ${{ inputs.image }} \
4854 --yes \
4955 --verbose
56+
57+ - name : Get input commit or latest commit
58+ id : commit
59+ shell : bash
60+ env :
61+ GH_TOKEN : ${{ inputs.gh_token }}
62+ run : |
63+ echo "url=${{ github.server_url }}/${{ github.repository }}/commits/${{ github.sha }}" >> $GITHUB_OUTPUT
64+
65+ - name : Get The PRs associated with the commit
66+ id : prs
67+ shell : bash
68+ env :
69+ GH_TOKEN : ${{ inputs.gh_token }}
70+ run : |
71+ prs=$(gh api \
72+ -H "Accept: application/vnd.github+json" \
73+ -H "X-GitHub-Api-Version: 2022-11-28" \
74+ /repos/${{ github.repository }}/commits/${{ github.sha }}/pulls)
75+
76+ echo "prs=$prs" >> $GITHUB_OUTPUT
77+ echo "prs $prs"
78+
79+ - name : Get ther run URL
80+ id : run
81+ shell : bash
82+ run : |
83+ echo "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
84+
85+ - name : Comment PR
86+ shell : bash
87+ env :
88+ GH_TOKEN : ${{ inputs.gh_token }}
89+ run : |
90+ cat <<EOF >> comment.txt
91+ This PR was shipped to (${{ inputs.environment }})
92+ - [commit](${{ steps.commit.outputs.url }})
93+ - version: ${{ inputs.version }}
94+ - image: ${{ inputs.image }}
95+
96+ [View the run](${{ steps.run.outputs.url }})
97+ EOF
98+
99+ for pr in $(echo '${{ steps.prs.outputs.prs }}' | jq -r '.[].number'); do
100+ gh api \
101+ --method POST \
102+ -H "Accept: application/vnd.github.v3+json" \
103+ /repos/${{ github.repository }}/pulls/$pr/reviews \
104+ -f body="$(cat comment.txt)" \
105+ -F event=COMMENT
106+ done
107+
50108 - name : Notify (scuccessful deployment)
51109 if : success()
52110 uses : ./.github/actions/slack
0 commit comments