This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
60 lines (59 loc) · 2.14 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Description: This workflow runs unit tests and builds PRs targeting `main`
#
# Triggered by:
# (1) Internal PRs: contirubutor pushes a commit to PRs targeting protected branches.
# (2) Fork PRs: maintainer adds "run-test" label to PRs targeting protected branches.
name: Build PRs
on:
pull_request_target:
branches: [main]
types: [opened, synchronize, labeled]
permissions:
pull-requests: write # used to remove label
id-token: write
contents: read
jobs:
setup:
runs-on: ubuntu-latest
# We run tests only if it's:
# 1) pull request not from a fork (ie. internal PR), or
# 2) pull request from a fork (ie. external PR) that was added "run-tests" label
if: |
(github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event.action == 'labeled' && github.event.label.name == 'run-tests')
steps:
- name: Remove run-tests label, if applicable
if: always() && github.event.label.name == 'run-tests'
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const label = 'run-tests';
github.issues.removeLabel({ owner, repo, issue_number, name: label });
build:
name: Build
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@main
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
- name: Setup Node.js 20.x
uses: actions/setup-node@main
with:
node-version: 20.x
- name: Install Dependencies
run: npm install
- name: Fetch Amplify backend configuration
uses: ./.github/actions/fetch_amplify_backend
with:
role-to-assume: ${{ secrets.AWS_ARN_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
app-id: ${{ secrets.APP_ID }}
env-name: ${{ secrets.ENV_NAME }}
- name: Run build
run: npm run build