Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
1.4 kB
3
Indexable
Never
name: 🚀 Deploy
on:
  push:
    branches:
      - main
      - dev
  pull_request: {}

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  actions: write
  contents: read

jobs:
  deploy:
    name: 🚀 Deploy
    runs-on: ubuntu-latest
    # only build/deploy main branch on pushes
    if:
      ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') &&
      github.event_name == 'push' }}

    steps:
      - name: ⬇️ Checkout repo
        uses: actions/checkout@v3

      - name: 👀 Read app name
        uses: SebRollen/toml-action@v1.0.2
        id: app_name
        with:
          file: "fly.toml"
          field: "app"

      - name: 🚀 Deploy Staging
        if: ${{ github.ref == 'refs/heads/dev' }}
        uses: superfly/flyctl-actions@1.3
        with:
          args:
            "deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app
            ${{ steps.app_name.outputs.value }}-staging"
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

      - name: 🚀 Deploy Production
        if: ${{ github.ref == 'refs/heads/main' }}
        uses: superfly/flyctl-actions@1.3
        with:
          args: "deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}"
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}