From c6f13d03da251da6044869d55b90c62e74825924 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 9 Jun 2024 20:30:25 +0100 Subject: [PATCH] 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 --- .github/workflows/deploy.yml | 66 +++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c009f0b..4c76754 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }}