dep_update_prod #2073
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
| # | |
| # Github Actions for Serverless Framework | |
| # | |
| # Create AWS_KEY and AWS_SECRET secrets in Github repository settings | |
| # If you're using env.yml file, store its content as ENV Github secret | |
| # | |
| # Master branch will be deployed as DEV and every new tag starting with "v**" (e.g. v1.0, v1.2, v2.0, etc) will be deployed as PROD | |
| # | |
| # Learn more: https://maxkostinevich.com/blog/how-to-deploy-serverless-applications-using-github-actions/ | |
| # | |
| name: Deploy Prod | |
| on: | |
| push: | |
| branches: | |
| - main | |
| repository_dispatch: | |
| types: [dep_update_prod] | |
| workflow_dispatch: | |
| concurrency: | |
| group: deploy-prod | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| uses: ./.github/workflows/ci-test.yml | |
| with: | |
| ap_deps_stage: prod | |
| ap_gameslib_version: ${{ github.event.client_payload.gameslib_version }} | |
| ap_renderer_version: ${{ github.event.client_payload.renderer_version }} | |
| ap_source: ${{ github.event.client_payload.source_run_id && format('gameslib-ci-{0}', github.event.client_payload.source_run_id) || '' }} | |
| secrets: | |
| PAT_READ_PACKAGES: ${{ secrets.PAT_READ_PACKAGES }} | |
| deploy-prod: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: "main" | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18.x' | |
| - name: Install Serverless Framework | |
| run: npm install -g serverless@3.38.0 | |
| - name: Serverless AWS authentication | |
| run: sls config credentials --provider aws --key ${{ secrets.AWS_KEY }} --secret ${{ secrets.AWS_SECRET }} | |
| # - name: Create env file | |
| # run: | # cp sample.env.yml env.yml | |
| # cat > env.yml << EOF | |
| # ${{ secrets.ENV }} | |
| # EOF | |
| - name: Create .npmrc | |
| run: echo "@abstractplay:registry=https://npm.pkg.github.com/" > .npmrc | |
| - run: echo "//npm.pkg.github.com/:_authToken=${{secrets.PAT_READ_PACKAGES}}" >> .npmrc | |
| - name: Install NPM dependencies | |
| run: npm ci | |
| - name: Check ci-deps manifests | |
| run: node bin/check-ci-deps.mjs | |
| - name: Install pinned AP dependencies | |
| env: | |
| AP_GAMESLIB_VERSION: ${{ github.event.client_payload.gameslib_version }} | |
| AP_RENDERER_VERSION: ${{ github.event.client_payload.renderer_version }} | |
| AP_SOURCE: ${{ github.event.client_payload.source_run_id && format('gameslib-ci-{0}', github.event.client_payload.source_run_id) || '' }} | |
| run: node bin/install-ap-deps.mjs --stage prod | |
| - name: Sync dependency manifests | |
| if: github.event_name == 'repository_dispatch' | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "deps: sync AP versions [skip ci]" | |
| file_pattern: | | |
| ci-deps.prod.json | |
| package-lock.json | |
| package.json | |
| - name: Set CI version | |
| run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version | |
| - name: Build | |
| run: npm run build-prod | |
| env: | |
| CI: false | |
| - name: Configure AWS credentials | |
| uses: Fooji/create-aws-profile-action@v1 | |
| with: | |
| profile: AbstractPlayProd | |
| region: us-east-1 | |
| key: ${{ secrets.AWS_KEY}} | |
| secret: ${{ secrets.AWS_SECRET}} | |
| # uses: aws-actions/configure-aws-credentials@v2 | |
| # with: | |
| # aws-access-key-id: ${{ secrets.AWS_KEY }} | |
| # aws-secret-access-key: ${{ secrets.AWS_SECRET }} | |
| # aws-region: us-east-1 | |
| - name: Deploy | |
| run: serverless client deploy --stage prod --no-confirm | |
| - name: Sync CloudFront CSP | |
| run: node bin/sync-cloudfront-csp.mjs --stage prod | |
| - name: Publish locale files to S3 | |
| run: node bin/publish-locales.mjs --stage prod | |
| - name: Trigger docs rebuild | |
| if: github.event_name == 'push' | |
| run: | | |
| BEFORE="${{ github.event.before }}" | |
| SHA="${{ github.sha }}" | |
| if [[ "$BEFORE" == "0000000000000000000000000000000000000000" ]]; then | |
| CHANGED="" | |
| for commit in ${{ join(github.event.commits.*.id, ' ') }}; do | |
| git fetch --depth=1 origin "$commit" | |
| CHANGED+="$(git show --name-only --pretty=format: "$commit")"$'\n' | |
| done | |
| else | |
| git fetch --depth=1 origin "$BEFORE" | |
| CHANGED="$(git diff --name-only "$BEFORE" "$SHA")" | |
| fi | |
| if echo "$CHANGED" | grep -q '^docs/'; then | |
| curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.PAT_WORKFLOWS }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/AbstractPlay/docs/dispatches \ | |
| -d '{"event_type":"dep_update_prod"}' | |
| fi | |
| # Optional (to use with serverless-finch serverless plugin) | |
| #- name: Deploy assets to S3 | |
| # run: sls client deploy --no-delete-contents --no-confirm -s dev |