FEAT: Deployment status (#25) #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π Deploy to Fly | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy app | |
runs-on: ubuntu-latest | |
concurrency: deploy-group | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v4 | |
- 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: Update GitHub Deployment Status to Success β | |
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() }} | |
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 }} |