Skip to content

Commit

Permalink
added multiple deployment options
Browse files Browse the repository at this point in the history
  • Loading branch information
rmrt1n committed Oct 15, 2021
1 parent 71416b1 commit be85a09
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,40 @@ on:
jobs:
set-deploy-type:
runs-on: ubuntu-latest
env:
VALID_TARGETS: ['gh-pages', 'firebase']
outputs:
target: ${{ steps.set-output.outputs.target }}
steps:
- uses: actions/checkout@v2

- name: get deployment target
run: TARGET=$(cat DEPLOY_STRATEGY)
run: |
TARGET=$(cat DEPLOY_STRATEGY)
echo "TARGET=$TARGET" >> $GITHUB_ENV
- name: check if target is valid
if: !(contains($VALID_TARGETS, $TARGET))
run: |
echo 'Invalid Deployment Target'
exit 1
if: success() && !contains(fromJSON('["gh-pages", "firebase", "none"]'), env.TARGET)
run: echo 'Invalid Deployment Target' && exit 1

# gh actions doesn't support using the 'env' context on job level ifs for
# some reason smh. here we use outputs instead
- name: set output to deploy target
id: set-output
run: echo "::set-output name=target::${{ env.TARGET }}"

# not sure if anyone wants this but I'm putting this here for those that don't
# want to host their site. else the actions will show an annoying x whenever
# you push to master
deploy-none:
runs-on: ubuntu-latest
needs: set-deploy-type
if: needs.set-deploy-type.outputs.target == 'none'
steps:
- run: echo 'No Deployment Specified' && exit 0

deploy-gh-pages:
runs-on: ubuntu-latest
needs: set-deploy-type
if: $TARGET == 'gh-pages'
if: needs.set-deploy-type.outputs.target == 'gh-pages'

steps:
- uses: actions/checkout@v2
Expand All @@ -40,7 +56,7 @@ jobs:
deploy-firebase:
runs-on: ubuntu-latest
needs: set-deploy-type
if: $TARGET == 'firebase'
if: needs.set-deploy-type.outputs.target == 'firebase'

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion DEPLOY_STRATEGY
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gh-pages
none

0 comments on commit be85a09

Please sign in to comment.