Skip to content

Commit 3367aab

Browse files
feat: ✨ Dockerize action code (#911)
1 parent 2773637 commit 3367aab

File tree

8 files changed

+30
-52
lines changed

8 files changed

+30
-52
lines changed

.github/workflows/app-stats.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,11 @@ jobs:
1717
with:
1818
id: ${{ secrets.APP_ID }}
1919
private_key: ${{ secrets.PRIVATE_KEY }}
20-
- run: "echo '{\"installations\": ${{ steps.stats.outputs.installations }}, \"repositories\": ${{ steps.stats.outputs.repositories }}, \"suspended\": ${{ steps.stats.outputs.suspended_installations }}, \"popular\": ${{ steps.stats.outputs.popular_repositories }} }' > public/stats.json"
2120

22-
- name: 'Commit Action Installation Statistics'
23-
run: |
24-
git config --local user.email "[email protected]"
25-
git config --local user.name "GitHub Action"
26-
git add public/stats.json
27-
git commit -m "Build by GitHub Actions" || true
28-
if: job.status == 'success'
21+
- run: "echo installations: '${{ steps.stats.outputs.installations }}'"
2922

30-
- name: 'Update repo'
31-
run: git pull --no-rebase
23+
- run: "echo repositories: '${{ steps.stats.outputs.repositories }}'"
3224

33-
- name: 'Push changes'
34-
uses: ad-m/github-push-action@master
35-
with:
36-
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
branch: ${{ github.ref }}
38-
if: job.status == 'success'
25+
- run: "echo suspended: '${{ steps.stats.outputs.suspended_installations }}'"
3926

27+
- run: "echo most popular repositories: '${{ steps.stats.outputs.popular_repositories }}'"

.github/workflows/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ jobs:
3838
- name: 'Upload code coverage report'
3939
run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_SECRET_TOKEN }}
4040

41+
- name: 'Build action dist'
42+
run: yarn action:dist
43+
44+
- name: 'Build action docker image'
45+
run: docker build -f Dockerfile-action -t cib-action .
46+
4147
- name: 'Build server dist'
4248
run: yarn server:dist
4349

44-
- name: 'Build docker image'
50+
- name: 'Build server docker image'
4551
run: docker build -t cib .
4652

4753
- name: 'Configure AWS credentials'

.github/workflows/release.yml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ jobs:
66
release:
77
name: Semantic Release
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
911
steps:
1012
- name: 'Checkout sources'
1113
uses: actions/checkout@v4
@@ -24,30 +26,13 @@ jobs:
2426
- name: 'Build GitHub Actions distribution'
2527
run: yarn action:dist
2628

29+
- name: 'Commit GitHub Actions distribution'
30+
uses: stefanzweifel/git-auto-commit-action@v5
31+
with:
32+
commit_message: Build by GitHub Actions
33+
file_pattern: action-dist/index.js
34+
2735
- name: 'Semantic Release'
28-
id: semantic
29-
uses: cycjimmy/semantic-release-action@v3
3036
env:
3137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: 'GitHub release'
34-
if: steps.semantic.outputs.new_release_published == 'true'
35-
uses: softprops/action-gh-release@v1
36-
with:
37-
tag_name: ${{ steps.semantic.outputs.new_release_version }}
38-
39-
- name: 'Commit GitHub Actions distribution'
40-
run: |
41-
git config --local user.email "[email protected]"
42-
git config --local user.name "GitHub Action"
43-
git add action-dist/index.js
44-
git commit -m "Build by GitHub Actions" || true
45-
if: job.status == 'success'
46-
47-
- name: 'Push changes'
48-
uses: ad-m/github-push-action@master
49-
with:
50-
github_token: ${{ secrets.GITHUB_TOKEN }}
51-
branch: ${{ github.ref }}
52-
force: true
53-
if: job.status == 'success'
38+
run: npx semantic-release

Dockerfile-action

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM node:20-alpine
2+
RUN mkdir /app
3+
COPY action-dist /app/action-dist
4+
WORKDIR /app
5+
CMD ["node", "./action-dist/index.js"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
[![Dependabot](https://badgen.net/badge/Dependabot/enabled/green?icon=dependabot)](https://dependabot.com/)
2121
[![Sentry](https://img.shields.io/badge/sentry-enabled-green)](https://sentry.io)
2222
![Vercel](https://vercelbadge.vercel.app/api/robvanderleek/create-issue-branch)
23+
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
24+
2325

2426
</div>
2527

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
],
2020
"plugins": [
2121
"@semantic-release/commit-analyzer",
22+
"@semantic-release/release-notes-generator",
2223
[
23-
"@semantic-release/npm",
24+
"@semantic-release/github",
2425
{
25-
"npmPublish": false
26+
"publish": true
2627
}
2728
],
2829
[

public/stats.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/probot.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default (app: Probot, {getRouter}: ApplicationFunctionOptions) => {
2121
const buildDate = gitDate.toISOString().substring(0, 10);
2222
app.log.info(`Create Issue Branch, version: ${version}, revison: ${gitSha.substring(0, 8)}, built on: ${buildDate}`);
2323
if (getRouter) {
24-
addStatsRoute(getRouter);
2524
addPlansRoute(app, getRouter);
2625
} else if (!isRunningInGitHubActions()) {
2726
app.log.info('Custom routes not available!')
@@ -109,13 +108,6 @@ async function insertEventIntoDatabase(app: Probot, ctx: any) {
109108
}
110109
}
111110

112-
function addStatsRoute(getRouter: (path?: string) => express.Router) {
113-
const router = getRouter('/probot')
114-
router.get('/stats', (req, res) => {
115-
res.redirect('https://raw.githubusercontent.com/robvanderleek/create-issue-branch/main/static/stats.json')
116-
})
117-
}
118-
119111
async function addPlansRoute(app: Probot, getRouter: (path?: string) => express.Router) {
120112
const router = getRouter('/probot')
121113
router.get('/plans', async (_, res) => {

0 commit comments

Comments
 (0)