Skip to content

Commit 063c589

Browse files
committed
Add github actions workflow - build check on every pr to main, prettier on every push and pr, releases are triggered manually via Github Actions
1 parent ea5887c commit 063c589

3 files changed

Lines changed: 212 additions & 0 deletions

File tree

.github/workflows/build_checks.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Build Checks"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check_vite:
10+
name: Check Vite Template
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Install dependencies, generate keys, and build
22+
run: |
23+
cd vite-iwa-template
24+
npm install
25+
26+
# Generate keys required for the build process
27+
export KEY_PASSWORD=$(openssl rand -base64 32)
28+
openssl genpkey -algorithm Ed25519 -out private_key.pem
29+
openssl pkcs8 -in private_key.pem -topk8 -out encrypted_key.pem -passout env:KEY_PASSWORD
30+
31+
# Create the .env file for the build
32+
echo "PRIVATE_KEY_PATH=encrypted_key.pem" > .env
33+
echo "PRIVATE_KEY_PASSWORD=$KEY_PASSWORD" >> .env
34+
echo "NODE_ENV='production'" >> .env
35+
36+
# Run the build
37+
npm run build
38+
39+
check_webpack:
40+
name: Check Webpack Template
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '20'
50+
51+
- name: Install dependencies, generate keys, and build
52+
run: |
53+
cd webpack-iwa-template
54+
npm install
55+
56+
# Generate keys required for the build process
57+
export KEY_PASSWORD=$(openssl rand -base64 32)
58+
openssl genpkey -algorithm Ed25519 -out private_key.pem
59+
openssl pkcs8 -in private_key.pem -topk8 -out encrypted_key.pem -passout env:KEY_PASSWORD
60+
61+
# Create the .env file for the build
62+
echo "PRIVATE_KEY_PATH=encrypted_key.pem" > .env
63+
echo "PRIVATE_KEY_PASSWORD=$KEY_PASSWORD" >> .env
64+
65+
# Run the build
66+
npm run build

.github/workflows/prettier.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Lint and Format'
2+
3+
# This workflow runs on pushes to any branch
4+
# and on any pull request
5+
on:
6+
[push, pull_request]
7+
8+
jobs:
9+
prettier-format-commit:
10+
name: Prettier format and commit
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Run Prettier and format files
23+
run: |
24+
npm install --global prettier
25+
# The --write flag modifies files in-place
26+
prettier --write . --config .prettierrc
27+
28+
- name: Commit formatted files
29+
uses: stefanzweifel/git-auto-commit-action@v5
30+
with:
31+
commit_message: "style: Auto-format files with Prettier"
32+
# Defaults to the current branch.
33+
# For pull requests, this commits to the head branch.

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: "Create Release"
2+
3+
on:
4+
# Allows manual triggering of the workflow to create a release.
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Release version (e.g., v1.2.3)'
9+
required: true
10+
type: string
11+
12+
jobs:
13+
build_vite:
14+
name: Build Vite Template
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
25+
- name: Install dependencies
26+
run: |
27+
cd vite-iwa-template
28+
npm install
29+
30+
- name: Generate private keys and build
31+
run: |
32+
cd vite-iwa-template
33+
export KEY_PASSWORD=$(openssl rand -base64 32)
34+
openssl genpkey -algorithm Ed25519 -out private_key.pem
35+
openssl pkcs8 -in private_key.pem -topk8 -out encrypted_key.pem -passout env:KEY_PASSWORD
36+
echo "PRIVATE_KEY_PATH=encrypted_key.pem" > .env
37+
echo "PRIVATE_KEY_PASSWORD=$KEY_PASSWORD" >> .env
38+
echo "NODE_ENV='production'" >> .env
39+
rm private_key.pem
40+
npm run build
41+
rm -rf node_modules dist encrypted_key.pem .env
42+
43+
- name: Zip project folder
44+
run: (cd vite-iwa-template && zip -r ../vite-template.zip .)
45+
46+
- name: Upload Vite artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: vite-template-artifact
50+
path: vite-template.zip
51+
52+
build_webpack:
53+
name: Build Webpack Template
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '20'
63+
64+
- name: Install dependencies
65+
run: |
66+
cd webpack-iwa-template
67+
npm install
68+
69+
- name: Generate private keys and build
70+
run: |
71+
cd webpack-iwa-template
72+
export KEY_PASSWORD=$(openssl rand -base64 32)
73+
openssl genpkey -algorithm Ed25519 -out private_key.pem
74+
openssl pkcs8 -in private_key.pem -topk8 -out encrypted_key.pem -passout env:KEY_PASSWORD
75+
echo "PRIVATE_KEY_PATH=encrypted_key.pem" > .env
76+
echo "PRIVATE_KEY_PASSWORD=$KEY_PASSWORD" >> .env
77+
rm private_key.pem
78+
npm run build
79+
rm -rf node_modules dist encrypted_key.pem .env
80+
81+
- name: Zip project folder content
82+
run: (cd webpack-iwa-template && zip -r ../webpack-template.zip .)
83+
84+
- name: Upload Webpack artifact
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: webpack-template-artifact
88+
path: webpack-template.zip
89+
90+
create_release:
91+
name: Create GitHub Release
92+
runs-on: ubuntu-latest
93+
needs: [build_vite, build_webpack]
94+
permissions:
95+
contents: write
96+
steps:
97+
- name: Download Vite artifact
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: vite-template-artifact
101+
102+
- name: Download Webpack artifact
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: webpack-template-artifact
106+
107+
- name: Create Release
108+
uses: ncipollo/release-action@v1
109+
with:
110+
tag: ${{ github.event.inputs.version }}
111+
name: Release ${{ github.event.inputs.version }}
112+
artifacts: "vite-template.zip,webpack-template.zip"
113+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)