default working directory #75
This file contains hidden or 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: Deployment | |
| on: | |
| push: | |
| branches: | |
| - development | |
| - main | |
| env: | |
| PIPELINE_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: | | |
| cd src | |
| npm ci | |
| npm run test | |
| deploy: | |
| if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Google Cloud Auth | |
| uses: 'google-github-actions/auth@v3' | |
| with: | |
| project_id: 'httparchive' | |
| credentials_json: ${{ env.PIPELINE_SA_KEY }} | |
| - uses: hashicorp/setup-terraform@v3 | |
| - name: Set environment variable depending on the branch name | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "ENV=prod" >> $GITHUB_ENV | |
| elif [[ "${{ github.ref }}" == "refs/heads/development" ]]; then | |
| echo "ENV=dev" >> $GITHUB_ENV | |
| fi | |
| - name: Terraform Validate & Plan | |
| id: plan | |
| run: make tf_plan ENV=${{ env.ENV }} | |
| continue-on-error: true | |
| - name: Terraform Plan status | |
| if: steps.plan.outcome == 'failure' | |
| run: exit 1 | |
| - name: Terraform Apply | |
| id: apply | |
| run: make tf_apply ENV=${{ env.ENV }} |