Lint staged #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
branches: | |
- main | |
- master | |
types: [closed] | |
jobs: | |
lint: | |
uses: ./.github/workflows/_lint.yml | |
permissions: | |
checks: write | |
contents: write | |
check-secrets: # thx https://stackoverflow.com/a/70249520/6612932 | |
runs-on: ubuntu-latest | |
needs: lint | |
outputs: | |
caprover-server: ${{ steps.caprover-server.outputs.defined }} | |
steps: | |
- name: Check for secrets.CAPROVER_SERVER availability | |
id: caprover-server | |
# perform secret check & put boolean result as an output | |
shell: bash | |
run: | | |
if [ "${{ secrets.CAPROVER_SERVER }}" != '' ]; then | |
echo "defined=true" >> $GITHUB_OUTPUT; | |
else | |
echo "defined=false" >> $GITHUB_OUTPUT; | |
fi | |
deploy: | |
# secret checked and action merged or pushed only | |
if: needs.check-secrets.outputs.caprover-server == 'true' && (github.event.pull_request.merged || github.event_name == 'push') | |
runs-on: ubuntu-latest | |
needs: check-secrets | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Set up npm | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install caprover | |
run: npm install -g caprover | |
- name: Deploy back | |
run: caprover deploy -h "${{ secrets.CAPROVER_SERVER }}" -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'main' -a "${{ secrets.CAPROVER_BACK_APPNAME }}" | |
- name: Deploy front | |
run: caprover deploy -h "${{ secrets.CAPROVER_SERVER }}" -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'main' -a "${{ secrets.CAPROVER_FRONT_APPNAME }}" |