Skip to content

Commit c6f13d0

Browse files
authored
FEAT: Deployment status (#25)
* deploy: Updates deploy workflow to create a GH deployment status in the repo * chore: Removes .vscode, because it was just using defaults * chore: Bumps octokit request action to 2.3.1 * chore: Use normal POST request for creating GitHub deployment
1 parent 5509951 commit c6f13d0

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

.github/workflows/deploy.yml

+39-27
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,51 @@ jobs:
1717
- name: Setup Fly 🧰
1818
uses: superfly/flyctl-actions/setup-flyctl@master
1919

20+
- name: Install GitHub CLI 🐙
21+
uses: actions/setup-gh@v3
22+
23+
- name: Create GitHub Deployment 🚢
24+
id: create_deployment
25+
run: |
26+
gh auth setup-git
27+
gh auth status
28+
gh api repos/${{ github.repository }}/deployments \
29+
-X POST \
30+
-F ref=${{ github.ref }} \
31+
-F environment=production \
32+
-F description="Deploying the application to Fly.io" \
33+
-F required_contexts=[] \
34+
-F auto_merge=false \
35+
-q '.id' > deployment-id.txt
36+
DEPLOYMENT_ID=$(cat deployment-id.txt)
37+
echo "deployment_id=$DEPLOYMENT_ID" >> $GITHUB_ENV
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
2041
- name: Deploy to Fly.io 🛩️
2142
id: deploy
2243
run: flyctl deploy --remote-only
2344
env:
2445
FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}
2546

26-
- name: Create GitHub Deployment Status 🚢
27-
id: create_deployment
28-
uses: peter-evans/create-or-update-deployment@v1
29-
with:
30-
token: ${{ secrets.GITHUB_TOKEN }}
31-
environment: production
32-
environment_url: https://api.web-check.xyz
33-
description: "Deploying the application to Fly.io"
34-
transient_environment: false
35-
auto_inactive: true
36-
3747
- name: Update GitHub Deployment Status to Success ✅
38-
if: success()
39-
uses: octokit/request-action@v2.3.1
40-
with:
41-
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.deployment_id }}/statuses
42-
token: ${{ secrets.GITHUB_TOKEN }}
43-
state: success
44-
environment_url: https://api.web-check.xyz
45-
description: '✅ Deployment successful! 🥳'
48+
if: ${{ success() }}
49+
run: |
50+
gh api repos/${{ github.repository }}/deployments/${{ env.deployment_id }}/statuses \
51+
-X POST \
52+
-F state=success \
53+
-F environment_url=https://api.web-check.xyz \
54+
-F description='✅ Deployment successful! 🥳'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4657

4758
- name: Update GitHub Deployment Status to Failure 🚫
48-
if: failure()
49-
uses: octokit/request-action@v2.3.1
50-
with:
51-
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.deployment_id }}/statuses
52-
token: ${{ secrets.GITHUB_TOKEN }}
53-
state: failure
54-
environment_url: https://api.web-check.xyz
55-
description: '🚫 Deployment failed 😥'
59+
if: ${{ failure() }}
60+
run: |
61+
gh api repos/${{ github.repository }}/deployments/${{ env.deployment_id }}/statuses \
62+
-X POST \
63+
-F state=failure \
64+
-F environment_url=https://api.web-check.xyz \
65+
-F description='🚫 Deployment failed 😥'
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)