From 9b1be96f882e005cbb52f05091f3cd58efdc6475 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:46:06 +0200 Subject: [PATCH 1/2] Finalizing... --- .github/workflows/app-stats.yml | 20 ++++---------------- .github/workflows/main.yml | 8 +++++++- .github/workflows/release.yml | 33 +++++++++------------------------ Dockerfile-action | 5 +++++ package.json | 5 +++-- public/stats.json | 1 - src/probot.ts | 8 -------- 7 files changed, 28 insertions(+), 52 deletions(-) create mode 100644 Dockerfile-action delete mode 100644 public/stats.json diff --git a/.github/workflows/app-stats.yml b/.github/workflows/app-stats.yml index 7161294f..73974cbe 100644 --- a/.github/workflows/app-stats.yml +++ b/.github/workflows/app-stats.yml @@ -17,23 +17,11 @@ jobs: with: id: ${{ secrets.APP_ID }} private_key: ${{ secrets.PRIVATE_KEY }} - - 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" - - name: 'Commit Action Installation Statistics' - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add public/stats.json - git commit -m "Build by GitHub Actions" || true - if: job.status == 'success' + - run: "echo installations: '${{ steps.stats.outputs.installations }}'" - - name: 'Update repo' - run: git pull --no-rebase + - run: "echo repositories: '${{ steps.stats.outputs.repositories }}'" - - name: 'Push changes' - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} - if: job.status == 'success' + - run: "echo suspended: '${{ steps.stats.outputs.suspended_installations }}'" + - run: "echo most popular repositories: '${{ steps.stats.outputs.popular_repositories }}'" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7ffd77a..1ddf640f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,10 +38,16 @@ jobs: - name: 'Upload code coverage report' run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_SECRET_TOKEN }} + - name: 'Build action dist' + run: yarn action:dist + + - name: 'Build action docker image' + run: docker build -f Dockerfile-action -t cib-action . + - name: 'Build server dist' run: yarn server:dist - - name: 'Build docker image' + - name: 'Build server docker image' run: docker build -t cib . - name: 'Configure AWS credentials' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ec6bc5d..e8e17ba6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,8 @@ jobs: release: name: Semantic Release runs-on: ubuntu-latest + permissions: + contents: write steps: - name: 'Checkout sources' uses: actions/checkout@v4 @@ -24,30 +26,13 @@ jobs: - name: 'Build GitHub Actions distribution' run: yarn action:dist + - name: 'Commit GitHub Actions distribution' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Build by GitHub Actions + file_pattern: action-dist/index.js + - name: 'Semantic Release' - id: semantic - uses: cycjimmy/semantic-release-action@v3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: 'GitHub release' - if: steps.semantic.outputs.new_release_published == 'true' - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ steps.semantic.outputs.new_release_version }} - - - name: 'Commit GitHub Actions distribution' - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add action-dist/index.js - git commit -m "Build by GitHub Actions" || true - if: job.status == 'success' - - - name: 'Push changes' - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} - force: true - if: job.status == 'success' + run: npx semantic-release diff --git a/Dockerfile-action b/Dockerfile-action new file mode 100644 index 00000000..5ada8b47 --- /dev/null +++ b/Dockerfile-action @@ -0,0 +1,5 @@ +FROM node:20-alpine +RUN mkdir /app +COPY action-dist /app/action-dist +WORKDIR /app +CMD ["node", "./action-dist/index.js"] diff --git a/package.json b/package.json index 23ce8a17..c8045d14 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,11 @@ ], "plugins": [ "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", [ - "@semantic-release/npm", + "@semantic-release/github", { - "npmPublish": false + "publish": true } ], [ diff --git a/public/stats.json b/public/stats.json deleted file mode 100644 index 8171b23e..00000000 --- a/public/stats.json +++ /dev/null @@ -1 +0,0 @@ -{"installations": 2362, "repositories": 86094, "suspended": 66, "popular": [{"id":16536608,"login":"guanguans","stars":11234},{"id":21032759,"login":"theodorusclarence","stars":4582},{"id":30926092,"login":"cubxxw","stars":1613},{"id":18889029,"login":"ALBINPRAVEEN","stars":1424},{"id":32793683,"login":"sailboatui","stars":1229},{"id":23337919,"login":"A-kirami","stars":986},{"id":12524329,"login":"deep5050","stars":956},{"id":25980848,"login":"megasanjay","stars":933},{"id":47309138,"login":"743859910","stars":741},{"id":45682579,"login":"astro-pi","stars":648}] } diff --git a/src/probot.ts b/src/probot.ts index 2a33380e..68c94a7d 100644 --- a/src/probot.ts +++ b/src/probot.ts @@ -21,7 +21,6 @@ export default (app: Probot, {getRouter}: ApplicationFunctionOptions) => { const buildDate = gitDate.toISOString().substring(0, 10); app.log.info(`Create Issue Branch, version: ${version}, revison: ${gitSha.substring(0, 8)}, built on: ${buildDate}`); if (getRouter) { - addStatsRoute(getRouter); addPlansRoute(app, getRouter); } else if (!isRunningInGitHubActions()) { app.log.info('Custom routes not available!') @@ -109,13 +108,6 @@ async function insertEventIntoDatabase(app: Probot, ctx: any) { } } -function addStatsRoute(getRouter: (path?: string) => express.Router) { - const router = getRouter('/probot') - router.get('/stats', (req, res) => { - res.redirect('https://raw.githubusercontent.com/robvanderleek/create-issue-branch/main/static/stats.json') - }) -} - async function addPlansRoute(app: Probot, getRouter: (path?: string) => express.Router) { const router = getRouter('/probot') router.get('/plans', async (_, res) => { From 6f08fb77594c9691bf7982a6ce929071795929da Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:53:33 +0200 Subject: [PATCH 2/2] Add SV badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d2e38a65..38c46d39 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ [![Dependabot](https://badgen.net/badge/Dependabot/enabled/green?icon=dependabot)](https://dependabot.com/) [![Sentry](https://img.shields.io/badge/sentry-enabled-green)](https://sentry.io) ![Vercel](https://vercelbadge.vercel.app/api/robvanderleek/create-issue-branch) +[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) +