Add PR Preview #1
Workflow file for this run
This file contains 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: CI Workflow for PR | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
pr-prebuild: | |
name: PR Prebuild | |
runs-on: ubuntu-latest | |
if: github.ref != 'refs/heads/master' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '21' | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Cache Yarn | |
uses: actions/cache@v3 | |
with: | |
path: | | |
.yarn/ | |
yarn.lock.sha256sum | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
- name: Install Dependencies | |
run: | | |
yarn install | |
- name: Build with sourcemaps | |
env: | |
REACT_APP_HTTP_PROTOCOL: ${{ vars.REACT_APP_HTTP_PROTOCOL }} | |
REACT_APP_API_URL: ${{ vars.REACT_APP_PREVIEW_API_URL }} | |
REACT_APP_URL: ${{ vars.REACT_APP_PREVIEW_URL }} | |
REACT_APP_WS_PROTOCOL: ${{ vars.REACT_APP_WS_PROTOCOL }} | |
CI: false | |
run: yarn run build_with_sourcemap | |
- name: Save git hash to version.txt | |
run: node get_git_hash.js > build/version.txt | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
include-hidden-files: true | |
path: build/ | |
deploy-s3-pr-preview: | |
name: Deploy to S3 for PR Preview | |
runs-on: ubuntu-latest | |
needs: pr-prebuild | |
if: github.ref != 'refs/heads/master' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: build | |
- name: Zip the build directory | |
run: | | |
cd build | |
find . -name "*.map" -type f -delete | |
zip -r app.zip . | |
cd ../ | |
- name: Set up AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: 'eu-west-3' # Update region if necessary | |
- name: Deploy to S3 | |
run: | | |
export BRANCH_HASH=$(git rev-parse --abbrev-ref HEAD | md5sum | awk '{print $1}') | |
aws s3 rm s3://iseplife-github-prs/$BRANCH_HASH --recursive | |
aws s3 cp build/ s3://iseplife-github-prs/$BRANCH_HASH --recursive |