-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: FE Build for admin | ||
|
||
on: | ||
push: | ||
branches: ["main", "develop"] | ||
paths: | ||
- "frontend-admin/**" | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./frontend-admin | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: "pnpm" | ||
cache-dependency-path: frontend-admin/pnpm-lock.yaml | ||
|
||
- name: Generate .env File | ||
working-directory: ./frontend | ||
run: | | ||
echo "API_BASE_URL=${{ secrets.API_BASE_URL_PROD }}" >> .env | ||
- name: Install Dependencies | ||
run: npm install | ||
working-directory: ./frontend-admin | ||
|
||
- name: Cache node_modules | ||
id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "**/node_modules" | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Build | ||
run: pnpm build | ||
working-directory: ./frontend-admin | ||
|
||
- name: Configure AWS CLI | ||
run: | | ||
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws configure set default.region ${{ secrets.AWS_REGION }} | ||
- name: Upload to S3 (Admin) | ||
working-directory: ./frontend-admin/dist | ||
run: | | ||
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET_ADMIN }} --delete | ||
- name: Invalidate CloudFront Cache (Admin) | ||
run: | | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_ADMIN }} --paths "/*" |