Merge pull request #10 from linaro-marketing/staging-add-deploy-action #1
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: Deploy-Serverless-Web-Forms | |
| on: | |
| push: | |
| branches: ["staging", "main"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: "20.x" | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| environment: | |
| name: ${{ github.ref == 'refs/heads/main' && 'prod' || 'staging' }} | |
| steps: | |
| - name: Fetch git repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::691071635361:role/github-actions-oidc-role | |
| aws-region: us-east-1 | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Prepare Form Data | |
| env: | |
| SERVICE_DESK_USERNAME: ${{ secrets.SERVICE_DESK_USERNAME }} | |
| SERVICE_DESK_API_KEY: ${{ secrets.SERVICE_DESK_API_KEY }} | |
| run: node setup_form_data.js --path config/formConfig.json --outPath form_data.json | |
| - name: Create .env file from secrets | |
| run: | | |
| cat <<EOF > .env | |
| VERIFICATION_FROM_EMAIL_ADDR=${{ secrets.VERIFICATION_FROM_EMAIL_ADDR }} | |
| VAULT_DOMAIN=${{ secrets.VAULT_DOMAIN }} | |
| VAULT_PORT=${{ secrets.VAULT_PORT }} | |
| VAULT_IAM_ROLE=${{ secrets.VAULT_IAM_ROLE }} | |
| VAULT_SECRET_PATH=${{ secrets.VAULT_SECRET_PATH }} | |
| SERVICE_DESK_USERNAME=${{ secrets.SERVICE_DESK_USERNAME }} | |
| SERVICE_DESK_API_KEY=${{ secrets.SERVICE_DESK_API_KEY }} | |
| SERVICE_DESK_DOMAIN=${{ secrets.SERVICE_DESK_DOMAIN }} | |
| PUBLIC_FRIENDLY_CAPTCHA_API_KEY=${{ secrets.PUBLIC_FRIENDLY_CAPTCHA_API_KEY }} | |
| PUBLIC_FRIENDLY_CAPTCHA_SITEKEY=${{ secrets.PUBLIC_FRIENDLY_CAPTCHA_SITEKEY }} | |
| EOF | |
| - name: Deploy Serverless | |
| run: | | |
| STAGE=${{ github.ref == 'refs/heads/main' && 'prod' || 'staging' }} | |
| npx serverless deploy --stage $STAGE |