From 3d9891b0771b8979e71b578ea6189f6a7d572dd7 Mon Sep 17 00:00:00 2001 From: Arthur Zapparoli Date: Wed, 12 Jul 2023 11:10:29 +0200 Subject: [PATCH] feat: adds fly deploy github action --- .github/renovate.json5 | 6 ++++ .github/workflows/fly-deploy.yaml | 51 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/fly-deploy.yaml diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 16e5412..4af37c9 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -29,6 +29,12 @@ "matchStrings": [ "datasource=(?.*?) depName=(?.*?)\\sARG .*?_VERSION=(?v.*)\\s" ] + }, + { + "fileMatch": ["^\\.github\\/workflows\\/fly-deploy\\.yaml$"], + "matchStrings": [ + "datasource=(?.*?) depName=(?.*?)\\sversion:\\s(?.*)\\s" + ] } ] } diff --git a/.github/workflows/fly-deploy.yaml b/.github/workflows/fly-deploy.yaml new file mode 100644 index 0000000..d283e8f --- /dev/null +++ b/.github/workflows/fly-deploy.yaml @@ -0,0 +1,51 @@ +name: Deploy to Fly + +on: + workflow_dispatch: {} + push: + branches: + - main + paths: + - Dockerfile + - fly.toml + - config/** + - scripts/** + +jobs: + check-fly-secret: + runs-on: ubuntu-latest + outputs: + fly-secret-exists: ${{ steps.fly-secret-check.outputs.defined }} + steps: + - name: Check for Fly secrets availability + id: fly-secret-check + # perform secret check & put boolean result as an output + shell: bash + run: | + if [ "${{ secrets.FLY_API_TOKEN }}" != '' ] && [ "${{ secrets.FLY_APP }}" != '' ]; then + echo "defined=true" >> $GITHUB_OUTPUT; + else + echo "defined=false" >> $GITHUB_OUTPUT; + fi + + deploy: + name: Deploy app + runs-on: ubuntu-latest + needs: [check-fly-secret] + if: needs.check-fly-secret.outputs.fly-secret-exists == 'true' + steps: + - uses: actions/checkout@v2 + - uses: superfly/flyctl-actions/setup-flyctl@master + with: + version: 0.1.54 + - name: Install Task + uses: arduino/setup-task@v1 + with: + # renovate: datasource=github-releases depName=go-task/task + version: 3.27.1 + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy app + run: flyctl deploy --remote-only -a $FLY_APP + env: + FLY_APP: ${{ secrets.FLY_APP }} + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}