Skip to content

Docs remote (DO NOT MERGE) #712

Docs remote (DO NOT MERGE)

Docs remote (DO NOT MERGE) #712

name: Preview
on:
pull_request:
types: [labeled, synchronize]
branches: [main]
concurrency:
group: pr_${{ github.head_ref }}
cancel-in-progress: true
env:
NODE_VERSION: '22.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:
build-rs-school:
name: Build rs.school
if: ${{ github.event.label.name == 'preview' || contains(github.event.pull_request.labels.*.name, 'preview') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build
run: |
npm ci --force
npm run build
- uses: jakejarvis/s3-sync-action@master
name: Sync to S3
with:
args: --cache-control max-age=300
env:
SOURCE_DIR: 'build'
DEST_DIR: rs-school-preview/pr${{ github.event.pull_request.number }}
create-preview:
name: Create Preview
runs-on: ubuntu-latest
needs: [build-rs-school]
steps:
- name: Trigger Preview Deployment
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: rolling-scopes/rsschool-infra
event-type: create-preview
client-payload: |
{
"number": ${{ github.event.pull_request.number }},
"ref": "${{ github.event.pull_request.head.ref }}",
"previewId": "pr${{ github.event.pull_request.number }}"
}
- name: Set deployment status
uses: apalchys/deployment-action@v1.2.6
id: deployment
with:
ref: ${{ github.event.pull_request.head.ref }}
pr: true
pr_id: ${{ github.event.pull_request.number }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
environment: pr${{ github.event.pull_request.number }}
initial_status: in_progress