Skip to content

Commit

Permalink
FEAT: Deployment status (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 authored Jun 9, 2024
1 parent c6f13d0 commit 77e3f0b
Showing 1 changed file with 26 additions and 43 deletions.
69 changes: 26 additions & 43 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main

jobs:
deploy:
name: Deploy app
Expand All @@ -13,55 +12,39 @@ jobs:
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 🚒
- 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 }}
uses: octokit/request-action@v2.3.1
with:
route: POST /repos/${{ github.repository }}/deployments
environment: production
ref: ${{ github.sha }}
description: "Deploying to Fly.io"
auto_merge: false

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

- name: Set deployment status to success βœ…
if: success()
uses: octokit/request-action@v2.3.1
with:
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.id }}/statuses
state: success
description: "βœ… Deployment Succeeded πŸ₯³"
environment: production

- 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 }}
- name: Set deployment status to failure ❌
if: failure()
uses: octokit/request-action@v2.3.1
with:
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.id }}/statuses
state: failure
description: "❌ Deployment Failed πŸ˜₯"
environment: production

0 comments on commit 77e3f0b

Please sign in to comment.