Skip to content

Commit 898941b

Browse files
authored
feat(workflows): add reusable workflows for GitHub Action repos (#22)
- Add gha-build.yml for Node.js TypeScript build/test pattern - Add gha-publish.yml for GitHub Action publishing with dist rebuild, tag creation, GitHub release, and social notifications
1 parent 169ade6 commit 898941b

2 files changed

Lines changed: 166 additions & 0 deletions

File tree

.github/workflows/gha-build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: GHA Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node-version-file:
7+
description: 'Path to Node version file (default: .node-version)'
8+
required: false
9+
type: string
10+
default: '.node-version'
11+
12+
jobs:
13+
build:
14+
name: TypeScript Tests
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version-file: ${{ inputs.node-version-file }}
25+
cache: npm
26+
27+
- name: Install Dependencies
28+
run: npm ci
29+
30+
- name: Check Format
31+
run: npm run format:check
32+
33+
- name: Lint
34+
run: npm run lint
35+
36+
- name: Test
37+
run: npm run ci-test

.github/workflows/gha-publish.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: GHA Publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., 1.2.0)'
8+
required: true
9+
type: string
10+
action-name:
11+
description: 'Human readable action name (e.g., "Visual Studio VSIX Versioner")'
12+
required: true
13+
type: string
14+
action-slug:
15+
description: 'GitHub Marketplace slug (e.g., "visual-studio-vsix-versioner")'
16+
required: true
17+
type: string
18+
action-description:
19+
description: 'Short description for social media embeds'
20+
required: true
21+
type: string
22+
node-version-file:
23+
description: 'Path to Node version file (default: .node-version)'
24+
required: false
25+
type: string
26+
default: '.node-version'
27+
secrets:
28+
BLUESKY_USERNAME:
29+
description: 'Bluesky username'
30+
required: true
31+
BLUESKY_APP_PASSWORD:
32+
description: 'Bluesky app password'
33+
required: true
34+
LINKEDIN_ACCESS_TOKEN:
35+
description: 'LinkedIn access token'
36+
required: true
37+
LINKEDIN_CLIENT_ID:
38+
description: 'LinkedIn client ID'
39+
required: true
40+
41+
jobs:
42+
changelog:
43+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
44+
secrets: inherit
45+
46+
release:
47+
needs: changelog
48+
runs-on: ubuntu-latest
49+
outputs:
50+
version: ${{ inputs.version }}
51+
52+
permissions:
53+
contents: write
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version-file: ${{ inputs.node-version-file }}
63+
cache: npm
64+
65+
- name: Install Dependencies
66+
run: npm ci
67+
68+
- name: Rebuild dist
69+
run: npm run bundle
70+
71+
- name: Commit dist changes
72+
run: |
73+
git config user.name "github-actions[bot]"
74+
git config user.email "github-actions[bot]@users.noreply.github.com"
75+
git add dist/
76+
git diff --staged --quiet || git commit -m "chore: rebuild dist for v${{ inputs.version }}"
77+
git push
78+
79+
- name: Create and push tag
80+
run: |
81+
git tag v${{ inputs.version }}
82+
git push origin v${{ inputs.version }}
83+
84+
- name: Create GitHub Release
85+
uses: softprops/action-gh-release@v1
86+
with:
87+
tag_name: v${{ inputs.version }}
88+
name: v${{ inputs.version }}
89+
body: ${{ needs.changelog.outputs.changelog }}
90+
91+
notify-bluesky:
92+
needs: release
93+
uses: CodingWithCalvin/.github/.github/workflows/bluesky-post.yml@main
94+
with:
95+
post_text: |
96+
🚀 ${{ inputs.action-name }} v${{ needs.release.outputs.version }} has been released!
97+
98+
${{ inputs.action-description }}
99+
100+
[📋 Release Notes](https://github.com/${{ github.repository }}/releases/tag/v${{ needs.release.outputs.version }})
101+
[📦 GitHub Marketplace](https://github.com/marketplace/actions/${{ inputs.action-slug }})
102+
103+
#github #githubactions #devops #automation
104+
embed_url: https://github.com/marketplace/actions/${{ inputs.action-slug }}
105+
embed_title: ${{ inputs.action-name }}
106+
embed_description: ${{ inputs.action-description }}
107+
secrets:
108+
BLUESKY_USERNAME: ${{ secrets.BLUESKY_USERNAME }}
109+
BLUESKY_APP_PASSWORD: ${{ secrets.BLUESKY_APP_PASSWORD }}
110+
111+
notify-linkedin:
112+
needs: release
113+
uses: CodingWithCalvin/.github/.github/workflows/linkedin-post.yml@main
114+
with:
115+
post_text: |
116+
🚀 ${{ inputs.action-name }} v${{ needs.release.outputs.version }} has been released!
117+
118+
${{ inputs.action-description }}
119+
120+
📋 Release Notes: https://github.com/${{ github.repository }}/releases/tag/v${{ needs.release.outputs.version }}
121+
📦 GitHub Marketplace: https://github.com/marketplace/actions/${{ inputs.action-slug }}
122+
123+
#github #githubactions #devops #automation
124+
article_url: https://github.com/marketplace/actions/${{ inputs.action-slug }}
125+
article_title: ${{ inputs.action-name }}
126+
article_description: ${{ inputs.action-description }}
127+
secrets:
128+
LINKEDIN_ACCESS_TOKEN: ${{ secrets.LINKEDIN_ACCESS_TOKEN }}
129+
LINKEDIN_CLIENT_ID: ${{ secrets.LINKEDIN_CLIENT_ID }}

0 commit comments

Comments
 (0)