Skip to content

ci: 👷 deploy to Fly isn't working well, plus move out env deletion to own file #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/delete-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Delete GitHub environment after merging

on:
pull_request:
types: [closed]
branches:
- main

jobs:
delete-environment:
# TODO: Remove this `if` and fix the workflow once we start deploying to Fly again.
if: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# TODO: This wasn't working correctly.
# This removes left over environments in GitHub from the building and deploying.
- name: Clean up GitHub environment
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/seedcase-project/${{ github.event.repository.name }}/environments/pr-${{ github.event.number }}
env:
GH_TOKEN: ${{ secrets.DELETE_ENV_TOKEN }}
24 changes: 12 additions & 12 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ jobs:
uses: seedcase-project/.github/.github/workflows/test.yml@main
needs: lint

deploy:
name: Deploy app
runs-on: ubuntu-latest
needs: test
# deploy:
# name: Deploy app
# runs-on: ubuntu-latest
# needs: test

concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
# concurrency: deploy-group # optional: ensure only one action runs at a time
# steps:
# - uses: actions/checkout@v4

- name: Deploy to Fly.io
uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# - name: Deploy to Fly.io
# uses: superfly/flyctl-actions/setup-flyctl@master
# - run: flyctl deploy --remote-only
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
62 changes: 28 additions & 34 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy PR Preview App

on:
pull_request:
types: [opened, reopened, synchronize, closed]
types: [opened, reopened, synchronize]
branches:
- main
paths-ignore:
Expand All @@ -22,10 +22,10 @@ on:
- _publish.yml
- _extensions/**

env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_REGION: ams
FLY_ORG: seedcase-project
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# FLY_REGION: ams
# FLY_ORG: seedcase-project

jobs:
lint:
Expand All @@ -35,37 +35,31 @@ jobs:
uses: seedcase-project/.github/.github/workflows/test.yml@main
needs: lint

staging-app:
runs-on: ubuntu-latest
needs: test
# staging-app:
# runs-on: ubuntu-latest
# needs: test

# Only run one deployment at a time per PR.
concurrency:
group: pr-${{ github.event.number }}
# # Only run one deployment at a time per PR.
# concurrency:
# group: pr-${{ github.event.number }}

# Create a GitHub deployment environment per staging app so it shows up
# in the pull request UI.
environment:
name: pr-${{ github.event.number }}
url: ${{ steps.deploy.outputs.url }}
# # Create a GitHub deployment environment per staging app so it shows up
# # in the pull request UI.
# environment:
# name: pr-${{ github.event.number }}
# url: ${{ steps.deploy.outputs.url }}

steps:
- uses: actions/checkout@v4
# steps:
# - uses: actions/checkout@v4

- name: Deploy preview of PR
id: deploy
uses: superfly/fly-pr-review-apps@1.2.1
with:
name: ${{ github.event.repository.name }}-pr-${{ github.event.number }}
# # Need to install direct from source, since their action is outdated
# - name: Install Fly CLI
# run: |
# curl -L https://fly.io/install.sh | sh
# echo "/home/runner/.fly/bin" >> $GITHUB_PATH

# This removes left over environments in GitHub from the building and deploying.
- name: Clean up GitHub environment
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/seedcase-project/${{ github.event.repository.name }}/environments/pr-${{ github.event.number }}
if: ${{ github.event.action == 'closed' }}
env:
GH_TOKEN: ${{ secrets.DELETE_ENV_TOKEN }}
# - name: Deploy preview of PR
# id: deploy
# uses: ...
# with:
# name: ${{ github.event.repository.name }}-pr-${{ github.event.number }}