Skip to content

feat: add preview deploy #1

feat: add preview deploy

feat: add preview deploy #1

Workflow file for this run

name: Preview Pull Request
# on:
# pull_request:
# branches: [master]
concurrency:
group: pr_${{ github.head_ref }}
cancel-in-progress: true
env:
NODE_VERSION: '20.x' # set this to the node version to use
AWS_S3_BUCKET: 'sites-frontend'
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'eu-central-1'
jobs:
rolling-scopes:
name: build rollingscopes.com
if: ${{ github.event.label.name == 'preview' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: build
env:
HOST: 'https://pr${{ github.event.pull_request.number }}.rollingscopes.com'
RS_SCHOOL_HOST: 'https://pr${{ github.event.pull_request.number }}.rs.school'
run: |
npm install
npm run build
- uses: jakejarvis/s3-sync-action@master
with:
args: --cache-control max-age=300
env:
SOURCE_DIR: 'build'
DEST_DIR: rolling-scopes-com-preview/pr${{ github.event.pull_request.number }}
rs-school:
name: build rs.school
if: ${{ github.event.label.name == 'preview' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: build
env:
HOST: 'https://rs.school'
run: |
npm install
npm run build
- uses: jakejarvis/s3-sync-action@master
with:
args: --cache-control max-age=300
env:
SOURCE_DIR: 'build'
DEST_DIR: rs-school-preview/pr${{ github.event.pull_request.number }}
preview:
name: deploy preview
if: ${{ github.event.label.name == 'preview' }}
runs-on: ubuntu-latest
needs: [rs-school, rolling-scopes]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
working-directory: ./deploy
run: |
npm ci
npx cdk deploy --require-approval never -c feature=pr${{ github.event.pull_request.number }} -c deployId=${GITHUB_RUN_ID}
- name: github deployment
uses: apalchys/[email protected]
id: deployment
with:
ref: ${{ github.event.pull_request.head.ref }}
pr: true
pr_id: ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}
target_url: https://pr${{ github.event.pull_request.number }}.rs.school
environment: pr${{ github.event.pull_request.number }}
initial_status: success