Skip to content

Commit fbe1587

Browse files
authored
Update deploy action and workflows (#35)
1 parent 1438b24 commit fbe1587

File tree

5 files changed

+137
-84
lines changed

5 files changed

+137
-84
lines changed

.github/actions/deploy/action.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
name: 'Deploy to fly'
22
description: 'Deploys a published image to fly'
33
inputs:
4+
environment:
5+
required: true
6+
description: "Which environment to deploy to"
47
image:
58
required: true
69
description: "Which image to deploy"
7-
config:
8-
required: true
9-
description: "Path to a fly.toml file"
1010
token:
1111
required: true
1212
description: "Access token for flyctl"
1313

1414
runs:
1515
using: 'composite'
1616
steps:
17+
- id: config_path
18+
shell: bash
19+
run: |
20+
config_path=${{ github.workspace }}/fly-${{ inputs.environment}}.toml
21+
22+
if [ ! -f "$config_path" ]; then
23+
echo "Could not find config file at $config_path"
24+
exit 1
25+
fi
26+
27+
echo "path=$config_path" >> $GITHUB_OUTPUT
28+
- name: Notify (attempt)
29+
uses: ./.github/actions/slack
30+
with:
31+
message: "deploying ${{ inputs.image }} to ${{ inputs.environment }} :rocket:"
32+
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
1733
- name: Deploy flyctl
1834
shell: bash
1935
run: |
2036
docker run \
2137
--rm \
22-
-v ${{ inputs.config }}:/workspace/fly.toml \
38+
-v ${{ steps.config_path.outputs.path}}:/workspace/fly.toml \
2339
--workdir /workspace \
2440
ghcr.io/superfly/flyctl:latest \
2541
deploy \
@@ -28,3 +44,16 @@ runs:
2844
-i ${{ inputs.image }} \
2945
--yes \
3046
--verbose
47+
- name: Notify (scuccessful deployment)
48+
if: success()
49+
uses: ./.github/actions/slack
50+
with:
51+
message: ":tada: Successfully deployed ${{ inputs.image }} to ${{ inputs.environment }} :white_check_mark:!"
52+
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
53+
- name: Notify (failed deployment)
54+
if: failure()
55+
uses: ./.github/actions/slack
56+
with:
57+
message: ":fail: Failed to deploy to ${{ inputs.environment }} :red_flag:!"
58+
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
59+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Deploy (development)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
environment: development
8+
url: https://test-github-features-development.fly.dev
9+
10+
jobs:
11+
deploy_development:
12+
runs-on: ubuntu-latest
13+
environment:
14+
name: ${{ github.env.environment }}
15+
url: ${{ github.env.url }}
16+
concurrency:
17+
group: ${{ github.env.environment }}
18+
cancel-in-progress: true
19+
steps:
20+
- uses: actions/checkout@v2
21+
- id: build
22+
uses: ./.github/actions/build
23+
with:
24+
push: true
25+
username: ${{ github.actor}}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Deploy
29+
uses: ./.github/actions/deploy
30+
with:
31+
environment: ${{ github.env.environment }}
32+
token: ${{ secrets.FLY_TOKEN }}
33+
image: ${{ steps.build.outputs.tags }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy (production)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
environment: production
10+
url: https://test-github-features.fly.dev
11+
12+
jobs:
13+
deploy_production:
14+
runs-on: ubuntu-latest
15+
environment:
16+
name: ${{ github.env.environment }}
17+
url: ${{ github.env.url }}
18+
concurrency:
19+
group: ${{ github.env.environment }}
20+
cancel-in-progress: true
21+
steps:
22+
- uses: actions/checkout@v2
23+
- id: build
24+
uses: ./.github/actions/build
25+
with:
26+
push: true
27+
username: ${{ github.actor}}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Deploy
31+
uses: ./.github/actions/deploy
32+
with:
33+
environment: ${{ github.env.environment }}
34+
token: ${{ secrets.FLY_TOKEN }}
35+
image: ${{ steps.build.outputs.tags }}

.github/workflows/deploy.staging.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy (staging)
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
7+
8+
env:
9+
environment: staging
10+
url: https://test-github-features-staging.fly.dev
11+
12+
jobs:
13+
deploy_staging:
14+
if: ${{ github.event_name == 'merge_group' }}
15+
runs-on: ubuntu-latest
16+
environment:
17+
name: ${{ github.env.environment }}
18+
url: ${{ github.env.url }}
19+
concurrency:
20+
group: ${{ github.env.environment }}
21+
cancel-in-progress: true
22+
steps:
23+
- uses: actions/checkout@v2
24+
- id: build
25+
uses: ./.github/actions/build
26+
with:
27+
push: true
28+
username: ${{ github.actor}}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Deploy
32+
uses: ./.github/actions/deploy
33+
with:
34+
environment: ${{ github.env.environment }}
35+
token: ${{ secrets.FLY_TOKEN }}
36+
image: ${{ steps.build.outputs.tags }}

.github/workflows/deploy.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)