Skip to content

Commit 77e3f0b

Browse files
authored
FEAT: Deployment status (#25)
1 parent c6f13d0 commit 77e3f0b

File tree

1 file changed

+26
-43
lines changed

1 file changed

+26
-43
lines changed

β€Ž.github/workflows/deploy.yml

+26-43
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
87
jobs:
98
deploy:
109
name: Deploy app
@@ -13,55 +12,39 @@ jobs:
1312
steps:
1413
- name: Checkout πŸ›ŽοΈ
1514
uses: actions/checkout@v4
16-
15+
1716
- name: Setup Fly 🧰
1817
uses: superfly/flyctl-actions/setup-flyctl@master
1918

20-
- name: Install GitHub CLI πŸ™
21-
uses: actions/setup-gh@v3
22-
23-
- name: Create GitHub Deployment 🚒
19+
- name: Create GitHub Deployment πŸ™
2420
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 }}
21+
uses: octokit/request-action@v2.3.1
22+
with:
23+
route: POST /repos/${{ github.repository }}/deployments
24+
environment: production
25+
ref: ${{ github.sha }}
26+
description: "Deploying to Fly.io"
27+
auto_merge: false
4028

4129
- name: Deploy to Fly.io πŸ›©οΈ
42-
id: deploy
4330
run: flyctl deploy --remote-only
4431
env:
4532
FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}
33+
34+
- name: Set deployment status to success βœ…
35+
if: success()
36+
uses: octokit/request-action@v2.3.1
37+
with:
38+
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.id }}/statuses
39+
state: success
40+
description: "βœ… Deployment Succeeded πŸ₯³"
41+
environment: production
4642

47-
- name: Update GitHub Deployment Status to Success βœ…
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 }}
57-
58-
- name: Update GitHub Deployment Status to Failure 🚫
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 }}
43+
- name: Set deployment status to failure ❌
44+
if: failure()
45+
uses: octokit/request-action@v2.3.1
46+
with:
47+
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.id }}/statuses
48+
state: failure
49+
description: "❌ Deployment Failed πŸ˜₯"
50+
environment: production

0 commit comments

Comments
Β (0)