Skip to content

Commit 9140bf7

Browse files
authored
ci(release): 👷 add github actions workflows (#55)
* ci(release): 👷 add github actions workflows * ci: 👷 restructure CI workflows - the action-semantic-pull-request action is not able to run as workflow_call - see amannn/action-semantic-pull-request#232 - see amannn/action-semantic-pull-request#271 * ci: 👷 run push workflow only on push action - rewrite the workflow as amannn/action-semantic-pull-request@v5 cannot run on push - do not run push workflow on pull_request action - do not run push workflow on pull_request_target action * ci: 👷 remove secret GITHUB_TOKEN - prevent variable name collision with system reserved name * ci: 🚧 remove secret GITHUB_TOKEN * ci: 🚧 try to get the changesets setup * ci: 🚧 fix unknown commits issue * ci: 🚧 fix unknown package * ci: 🚧 fix local action run * ci: 🚧 simplify workflows
1 parent 43065a8 commit 9140bf7

File tree

7 files changed

+256
-33
lines changed

7 files changed

+256
-33
lines changed

.github/workflows/deploy.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy Web Application
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build_directory:
7+
description: The directory containing the build files to deploy.
8+
required: true
9+
type: string
10+
remote_server:
11+
description: The SSH address of the remote server (e.g., `user@host`).
12+
required: true
13+
type: string
14+
remote_path:
15+
description: The path on the remote server where files should be deployed.
16+
required: true
17+
type: string
18+
secrets:
19+
SSH_PRIVATE_KEY:
20+
required: true
21+
22+
jobs:
23+
deploy:
24+
name: 🚀 Deploy to Remote Server
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Download Build Artifacts
28+
uses: actions/download-artifact@v3
29+
with:
30+
name: build-artifacts
31+
32+
- name: Deploy using Rsync
33+
uses: burnett01/rsync-deployments@6.0.0
34+
with:
35+
switches: -avrh --delete
36+
path: src/
37+
remote_path: /var/www/virtual/${{ vars.SSH_USERNAME }}/Applications/vocabulary.genius7.com
38+
remote_host: ${{ vars.SSH_HOST }}
39+
remote_user: ${{ vars.SSH_USERNAME }}
40+
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 📝 Generate Changesets
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
pull_request_ref:
7+
description: The branch ref for the pull request (e.g., `github.event.pull_request.head.ref`).
8+
required: true
9+
type: string
10+
node_version:
11+
description: The Node.js version to use.
12+
required: true
13+
type: string
14+
15+
jobs:
16+
generate-changesets:
17+
name: 📝 Generate Changesets
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- uses: pnpm/action-setup@v4
24+
name: Install pnpm
25+
with:
26+
run_install: false
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ inputs.node_version }}
32+
cache: "pnpm"
33+
34+
- name: Install dependencies
35+
run: pnpm install
36+
37+
- name: Parse Conventional Commits
38+
run: |
39+
echo "🔍 Analyze Commits..."
40+
npx --no-install semantic-release-commit-analyzer
41+
echo "Creating Changesets based on commit types..."
42+
pnpm changeset --yes
43+
44+
- name: Commit Changeset Files
45+
if: ${{ github.event_name == 'pull_request' }}
46+
run: |
47+
git config user.name "GitHub Actions Bot"
48+
git config user.email "actions@github.com"
49+
git add .changeset/
50+
git commit -m "chore: auto-generated changesets based on commits"
51+
git push origin ${{ inputs.pull_request_ref }}

.github/workflows/conventional_commits.yml renamed to .github/workflows/on_pull_request.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
name: "🚨 Lint PR"
1+
name: Pull Request Workflow
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types:
66
- opened
7-
- edited
87
- synchronize
8+
- reopened
9+
branches:
10+
- main # Only trigger this workflow for pull requests targeting the main branch
911

1012
permissions:
1113
pull-requests: write
14+
contents: read
1215

1316
jobs:
14-
main:
15-
name: 🦺 Validate PR title
17+
validate-pr-or-commits:
18+
name: 🦺 Validate PR Title or Commit Messages
1619
runs-on: ubuntu-latest
1720
permissions:
1821
pull-requests: read

.github/workflows/on_push_feature.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Feature Branch Push Workflow
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- "main"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
validate-commit-messages:
13+
name: 🦺 Validate Commit Messages
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event_name != 'pull_request' }}
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Fetch the full history to ensure all commits are available
21+
22+
- uses: pnpm/action-setup@v4
23+
name: Install pnpm
24+
with:
25+
run_install: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "20"
31+
cache: "pnpm"
32+
33+
- name: Install dependencies
34+
run: pnpm install
35+
36+
- name: Fetch Commit Messages
37+
id: commits
38+
run: |
39+
echo "Fetching commit messages..."
40+
git log --format=%s HEAD~10..HEAD > commit_messages.txt || git log --format=%s > commit_messages.txt
41+
echo "Commit messages fetched:"
42+
cat commit_messages.txt
43+
44+
- name: Validate Commit Messages
45+
run: |
46+
echo "Validating commit messages..."
47+
npx commitlint --from=HEAD~10 --to=HEAD || npx commitlint --from=HEAD~1 --to=HEAD

.github/workflows/on_push_main.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 🔖 Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger the release workflow when changes are pushed to the main branch
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- uses: pnpm/action-setup@v4
20+
name: Install pnpm
21+
with:
22+
run_install: false
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "20"
28+
cache: "pnpm"
29+
30+
- name: Install dependencies
31+
run: pnpm install
32+
33+
- name: Create Release Pull Request
34+
id: changesets
35+
uses: changesets/action@v1
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+42-28
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,55 @@
1-
name: 🔖 Release
1+
name: Deploy Web Application
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
8-
concurrency: ${{ github.workflow }}-${{ github.ref }}
4+
workflow_call:
5+
inputs:
6+
node_version:
7+
description: The Node.js version to use for the workflow.
8+
required: true
9+
type: string
10+
build_directory:
11+
description: The directory containing the build files to deploy.
12+
required: true
13+
type: string
914

1015
jobs:
1116
release:
12-
name: 🔖 Release
17+
name: 🔖 Create Release
18+
1319
runs-on: ubuntu-latest
1420
steps:
15-
- name: Checkout Repo
16-
uses: actions/checkout@v3
17-
18-
- uses: pnpm/action-setup@v4
19-
name: Install pnpm
21+
- name: Setup
22+
uses: ./.github/workflows/setup.yml
2023
with:
21-
run_install: false
24+
node_version: ${{ inputs.node_version }} # Use the Node.js version passed from the calling workflow
25+
- name: Apply Changesets
26+
run: pnpm changeset version
2227

23-
- name: Install Node.js
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: 20
27-
cache: "pnpm"
28+
- name: Build Application
29+
run: pnpm build
2830

29-
- name: Install dependencies
30-
run: pnpm install
31-
32-
- name: Validate Turborepo Build
33-
run: pnpm turbo run build
34-
35-
- name: Create Release Pull Request
36-
uses: changesets/action@v1
31+
- name: Upload Build Artifacts
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: build-artifacts
35+
path: ${{ inputs.build_directory }} # Use the build directory passed from the calling workflow
36+
37+
- name: Commit Version Bumps
38+
run: |
39+
git config user.name "GitHub Actions Bot"
40+
git config user.email "actions@github.com"
41+
git add .
42+
git commit -m "chore: apply version bumps"
43+
git push origin main
44+
45+
- name: Push Tags
46+
run: git push --tags
47+
48+
- name: Create GitHub Release
49+
uses: softprops/action-gh-release@v2
3750
with:
38-
commit: "chore: :bookmark: update versions and changelog"
39-
title: "chore: :bookmark: version bump and changelog update"
51+
tag_name: ${{ github.ref_name }}
52+
name: Release ${{ github.ref_name }}
53+
body_path: ./CHANGELOG.md
4054
env:
4155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/setup.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 🛠️ Setup Environment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node_version:
7+
description: The Node.js version to use.
8+
required: true
9+
type: string
10+
11+
jobs:
12+
setup:
13+
name: 🛠️ Setup Environment
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- uses: pnpm/action-setup@v4
20+
name: Install pnpm
21+
with:
22+
run_install: false
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ inputs.node_version }}
28+
cache: "pnpm"
29+
30+
- name: Install dependencies
31+
run: pnpm install

0 commit comments

Comments
 (0)