Skip to content

Commit

Permalink
FEAT: Deployment status (#25)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Lissy93 authored Jun 9, 2024
1 parent 5509951 commit c6f13d0
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,51 @@ jobs:
- name: Setup Fly 🧰
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Install GitHub CLI πŸ™
uses: actions/setup-gh@v3

- name: Create GitHub Deployment 🚒
id: create_deployment
run: |
gh auth setup-git
gh auth status
gh api repos/${{ github.repository }}/deployments \
-X POST \
-F ref=${{ github.ref }} \
-F environment=production \
-F description="Deploying the application to Fly.io" \
-F required_contexts=[] \
-F auto_merge=false \
-q '.id' > deployment-id.txt
DEPLOYMENT_ID=$(cat deployment-id.txt)
echo "deployment_id=$DEPLOYMENT_ID" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to Fly.io πŸ›©οΈ
id: deploy
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}

- name: Create GitHub Deployment Status 🚒
id: create_deployment
uses: peter-evans/create-or-update-deployment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: production
environment_url: https://api.web-check.xyz
description: "Deploying the application to Fly.io"
transient_environment: false
auto_inactive: true

- name: Update GitHub Deployment Status to Success βœ…
if: success()
uses: octokit/request-action@v2.3.1
with:
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.deployment_id }}/statuses
token: ${{ secrets.GITHUB_TOKEN }}
state: success
environment_url: https://api.web-check.xyz
description: 'βœ… Deployment successful! πŸ₯³'
if: ${{ success() }}
run: |
gh api repos/${{ github.repository }}/deployments/${{ env.deployment_id }}/statuses \
-X POST \
-F state=success \
-F environment_url=https://api.web-check.xyz \
-F description='βœ… Deployment successful! πŸ₯³'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update GitHub Deployment Status to Failure 🚫
if: failure()
uses: octokit/request-action@v2.3.1
with:
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.deployment_id }}/statuses
token: ${{ secrets.GITHUB_TOKEN }}
state: failure
environment_url: https://api.web-check.xyz
description: '🚫 Deployment failed πŸ˜₯'
if: ${{ failure() }}
run: |
gh api repos/${{ github.repository }}/deployments/${{ env.deployment_id }}/statuses \
-X POST \
-F state=failure \
-F environment_url=https://api.web-check.xyz \
-F description='🚫 Deployment failed πŸ˜₯'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit c6f13d0

Please sign in to comment.