Skip to content

Commit 39c5fdf

Browse files
committed
Add GitHub Actions workflow to deploy to AWS
1 parent 3345c0f commit 39c5fdf

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy
2+
3+
concurrency:
4+
group: production
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches: [main]
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
build:
17+
name: Build
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Use Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '22'
28+
29+
- name: Enable Corepack
30+
run: corepack enable
31+
32+
- name: Install dependencies
33+
run: yarn --immutable
34+
35+
- name: Build
36+
run: yarn build
37+
38+
- name: Upload artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: package
42+
path: dist
43+
include-hidden-files: true
44+
45+
deploy:
46+
name: Deploy
47+
needs: build
48+
runs-on: ubuntu-latest
49+
environment:
50+
name: production
51+
url: https://projects.wojtekmaj.pl
52+
53+
steps:
54+
- name: Download artifact
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: package
58+
path: dist
59+
60+
- name: Configure AWS Credentials
61+
uses: aws-actions/configure-aws-credentials@v4
62+
with:
63+
role-to-assume: arn:aws:iam::692859910433:role/GitHubActionsProjects
64+
aws-region: eu-central-1
65+
66+
- name: Deploy
67+
run: |
68+
aws s3 cp --recursive --cache-control 'public, max-age=31557600' ./dist s3://$S3_BUCKET/react-lifecycle-methods-diagram
69+
aws s3 cp --metadata-directive REPLACE --cache-control 'public, max-age=180' --content-type 'text/html' s3://$S3_BUCKET/react-lifecycle-methods-diagram/index.html s3://$S3_BUCKET/react-lifecycle-methods-diagram/index.html
70+
env:
71+
S3_BUCKET: wojtekmaj-projects

0 commit comments

Comments
 (0)