Skip to content

Commit

Permalink
Free-main (#24)
Browse files Browse the repository at this point in the history
* remove push on main restriction

* fix deployments
  • Loading branch information
KevinMind authored Mar 15, 2024
1 parent e4343a9 commit 0564093
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
7 changes: 0 additions & 7 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ outputs:
runs:
using: "composite"
steps:
- name: Validate inputs
shell: bash
run: |
if [[ "${{ inputs.push }}" == "true" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Cannot push to registry from main branch unless we migrate our main build job to GHA."
exit 1
fi
# Setup docker to build for multiple architectures
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down
26 changes: 26 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Deploy to fly'
description: 'Deploys a published image to fly'
inputs:
image:
required: true
description: "Which image to deploy"
default: "false"
app:
required: true
description: "Which environment to deploy to"
token:
required: true
description: "Access token for flyctl"

runs:
using: "composite"
steps:
- name: Deploy to fly
shell: bash
run: |
flyctl deploy \
-t ${{ inputs.token }} \
-i ${{ inputs.image }} \
-a ${{ inputs.app }} \
--yes \
--verbose
28 changes: 13 additions & 15 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,37 @@ on:
branches:
- main

env:
environment: staging

jobs:
log:
runs-on: ubuntu-latest
steps:
- name: Log event
run: |
echo "json: ${{ github }}"
printenv
deploy_staging:
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2
- id: build
uses: ./.github/actions/build
with:
push: true
username: ${{ github.actor}}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to staging
run: |
echo "Deploying to staging"
# Your deployment script here

- name: Deploy to (${{ env.environment }})
uses: ./.github/actions/deploy
with:
app: ${{ env.environment }}
token: ${{ secrets.FLY_TOKEN }}
iamge: ${{ steps.build.outputs.tags }}
- name: Notify (scuccessful deployment)
if: success()
uses: ./.github/actions/slack
with:
message: ":tada: Deployed to staging :white_check_mark: successfully!"
message: ":tada: Deployed to ${{ env.environment }} :white_check_mark: successfully!"
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify (failed deployment)
if: failure()
uses: ./.github/actions/slack
with:
message: ":fail: Failed to deploy to staging :red_flag: successfully!"
message: ":fail: Failed to deploy to ${{ env.environment }} :red_flag: successfully!"
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
19 changes: 12 additions & 7 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- main

env:
environment: production

jobs:
log:
runs-on: ubuntu-latest
Expand All @@ -23,20 +26,22 @@ jobs:
push: true
username: ${{ github.actor}}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to production
run: |
echo "Deploying to production"
# Your deployment script here

- name: Deploy to (${{ env.environment }})
uses: ./.github/actions/deploy
with:
app: ${{ env.environment }}
token: ${{ secrets.FLY_TOKEN }}
iamge: ${{ steps.build.outputs.tags }}
- name: Notify (scuccessful deployment)
if: success()
uses: ./.github/actions/slack
with:
message: ":tada: Deployed to production :white_check_mark: successfully!"
message: ":tada: Deployed to ${{ env.environment }} :white_check_mark: successfully!"
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify (failed deployment)
if: failure()
uses: ./.github/actions/slack
with:
message: ":fail: Failed to deploy to production :red_flag: successfully!"
message: ":fail: Failed to deploy to ${{ env.environment }} :red_flag: successfully!"
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 0564093

Please sign in to comment.