Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit cf9ea52

Browse files
authored
feat: add default github repo files (#562)
1 parent ea018df commit cf9ea52

14 files changed

+409
-156
lines changed

.github/CODEOWNERS

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# Users referenced in this file will automatically be requested as reviewers for
2-
# PRs that modify the given paths
3-
# See https://help.github.com/articles/about-code-owners/, https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
1+
# GitHub CODEOWNERS file
2+
# Documentation:
3+
# - https://help.github.com/articles/about-code-owners/
4+
# - https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
45

5-
# All code
6+
# Syntax:
7+
# pattern @user-or-team
8+
# The last matching pattern takes precedence.
9+
10+
###############################
11+
# Repository Default Owners
12+
###############################
13+
# These owners will be the default owners for everything in the repo
614
* @ruzickap

.github/renovate.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
enabled: true,
2626
schedule: ["before 6am on Sunday"],
2727
},
28+
// Package update rules
2829
packageRules: [
2930
{
31+
description: "Disable auto-merge for major updates",
3032
matchUpdateTypes: ["major"],
3133
automerge: false,
3234
},
@@ -45,6 +47,7 @@
4547
],
4648
prBodyTemplate: "{{{table}}}{{{notes}}}{{{changelogs}}}",
4749
rebaseWhen: "behind-base-branch",
50+
// Custom version extraction
4851
regexManagers: [
4952
{
5053
extractVersionTemplate: "{{#if extractVersion}}{{{extractVersion}}}{{else}}^v?(?<version>.+)${{/if}}",

.github/workflows/codeql-actions.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "CodeQL GitHub Actions"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
paths:
9+
- .github/workflows/*.yml
10+
schedule:
11+
- cron: 17 10 * * 2
12+
13+
permissions: read-all
14+
15+
jobs:
16+
analyze-actions:
17+
name: Analyze GitHub Actions
18+
runs-on: "ubuntu-latest"
19+
permissions:
20+
# required for all workflows
21+
security-events: write
22+
# required to fetch internal or private CodeQL packs
23+
packages: read
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
28+
# Initializes the CodeQL tools for scanning.
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
31+
with:
32+
languages: actions
33+
build-mode: none
34+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
35+
queries: security-extended
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
39+
with:
40+
category: "/language:actions"

.github/workflows/links.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/mega-linter.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,35 @@ on:
1010
permissions: read-all
1111

1212
jobs:
13+
github-context:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Debug
17+
env:
18+
GITHUB_CONTEXT: ${{ toJson(github) }}
19+
run: |
20+
echo "${GITHUB_CONTEXT}"
21+
1322
mega-linter:
1423
runs-on: ubuntu-latest
24+
if: ${{ (!startsWith(github.ref_name, 'renovate/') && !startsWith(github.ref_name, 'release-please--')) || github.event_name == 'workflow_dispatch' }}
1525
timeout-minutes: 30
1626
steps:
1727
- name: Checkout Code
1828
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1929

20-
- name: Restore lychee cache
21-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
22-
with:
23-
path: .lycheecache
24-
key: cache-lychee-${{ github.sha }}
25-
restore-keys: cache-lychee-
26-
2730
- name: Extract commands from markdown files
2831
run: |
2932
set -euxo pipefail
33+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
34+
brew install mdq
3035
echo '#!/usr/bin/env bash' > README.sh
31-
find . -name '*.md' -print0 | while IFS= read -r -d '' FILE; do
32-
# Extract: ```bash ... ```
33-
sed -n "/^\`\`\`\(bash\|shell\)$/,/^\`\`\`$/p" "${FILE}" | sed '/^```*/d' >> README.sh
34-
# Extract: ```bash ... ```
35-
sed -n "/^ \`\`\`\(bash\|shell\)$/,/^ \`\`\`$/p" "${FILE}" | sed '/^ ```*/d; s/^ //' >> README.sh
36-
done
36+
readarray -d '' MD_FILES < <(find . -type f -name "*.md" -print0)
37+
mdq '```/^bash$|^shell$|^sh$/' --br -o plain "${MD_FILES[@]}" >> README.sh || true
3738
chmod a+x README.sh
3839
3940
- name: 💡 MegaLinter
40-
uses: oxsecurity/megalinter@146333030da68e2e58c6ff826633824fabe01eaf # v8.5.0
41+
uses: oxsecurity/megalinter@04cf22b980c2e9c2121553417ed651c944afc8e1 # v8.6.0
4142
env:
4243
GITHUB_COMMENT_REPORTER: false
4344
# Disabled due to error: [GitHub Status Reporter] Error posting Status for REPOSITORY with ...: 403
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: pr-slack-notification
2+
3+
# Based on: https://github.com/slackapi/slack-github-action/issues/269
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
types:
9+
- opened
10+
- ready_for_review
11+
- review_requested
12+
- closed
13+
issue_comment:
14+
types:
15+
- created
16+
pull_request_review:
17+
types:
18+
- submitted
19+
20+
permissions: read-all
21+
22+
defaults:
23+
run:
24+
shell: bash -euxo pipefail {0}
25+
26+
jobs:
27+
github-context:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Debug
31+
env:
32+
GITHUB_CONTEXT: ${{ toJson(github) }}
33+
run: |
34+
echo "${GITHUB_CONTEXT}"
35+
36+
pr-slack-notification:
37+
runs-on: ubuntu-latest
38+
name: Sends a message to Slack when a PR is opened
39+
if: (github.event.action == 'opened' && github.event.pull_request.draft == false) || github.event.action == 'ready_for_review'
40+
steps:
41+
- name: Post PR summary message to slack
42+
id: message
43+
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
44+
with:
45+
method: chat.postMessage
46+
token: ${{ secrets.MY_SLACK_BOT_TOKEN }}
47+
payload: |
48+
channel: ${{ secrets.MY_SLACK_CHANNEL_ID }}
49+
text: "💡 *${{ github.event.pull_request.user.login }}*: <${{ github.event.repository.html_url }}|${{ github.repository }}> - <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}> (+${{ github.event.pull_request.additions }}, -${{ github.event.pull_request.deletions }})"
50+
51+
- name: Create file with slack message timestamp
52+
env:
53+
TS: ${{ steps.message.outputs.ts }}
54+
run: |
55+
echo "${TS}" > slack-message-timestamp.txt
56+
57+
- name: Cache slack message timestamp
58+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
59+
with:
60+
path: slack-message-timestamp.txt
61+
key: slack-message-timestamp-${{ github.event.pull_request.html_url }}-${{ steps.message.outputs.ts }}
62+
63+
slack-emoji-react:
64+
runs-on: ubuntu-latest
65+
name: Adds emoji reaction to slack message when a PR is closed or reviewed
66+
if: ${{ startsWith(github.event.pull_request.html_url, 'https') || startsWith(github.event.issue.pull_request.html_url, 'https') }}
67+
steps:
68+
# gh commands needs to be executed in the repository
69+
- name: Checkout Code
70+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
72+
# https://stackoverflow.com/questions/74640750/github-actions-not-finding-cache
73+
# I can not use the cache action in this job because the cache is not shared between runs
74+
- name: Save slack timestamp as an environment variable
75+
id: slack-timestamp
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
GITHUB_PULL_REQUEST_HTML_URL: ${{ github.event.pull_request.html_url || github.event.issue.pull_request.html_url }}
79+
run: |
80+
SLACK_TIMESTAMP=$(gh cache list --json key --jq "[.[].key|capture(\"${GITHUB_PULL_REQUEST_HTML_URL}-(?<x>.+)\").x][0]")
81+
echo "SLACK_TIMESTAMP=${SLACK_TIMESTAMP}" | tee -a "${GITHUB_ENV}"
82+
if [[ "${SLACK_TIMESTAMP}" != '' ]]; then
83+
echo "github_event_pull_request_html_url=true" >> "${GITHUB_OUTPUT}"
84+
fi
85+
86+
- name: Decide which emoji to add
87+
if: ${{ steps.slack-timestamp.outputs.github_event_pull_request_html_url == 'true' }}
88+
env:
89+
GITHUB_EVENT_ACTION: ${{ github.event.action }}
90+
GITHUB_EVENT_NAME: ${{ github.event_name }}
91+
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}
92+
run: |
93+
case "${GITHUB_EVENT_ACTION}" in
94+
created)
95+
if [[ "${GITHUB_EVENT_NAME}" == 'issue_comment' ]]; then
96+
echo "EMOJI=speech_balloon" >> "${GITHUB_ENV}" # 💬
97+
fi
98+
;;
99+
submitted)
100+
case "${GITHUB_EVENT_REVIEW_STATE}" in
101+
changes_requested)
102+
echo "EMOJI=repeat" >> "${GITHUB_ENV}" # 🔁
103+
;;
104+
approved)
105+
echo "EMOJI=ok" >> "${GITHUB_ENV}" # 🆗
106+
;;
107+
commented)
108+
echo "EMOJI=speech_balloon" >> "${GITHUB_ENV}" # 💬
109+
;;
110+
esac
111+
;;
112+
review_requested)
113+
echo "EMOJI=eyes" >> "${GITHUB_ENV}" # 👀
114+
;;
115+
*)
116+
echo "EMOJI=false" >> "${GITHUB_ENV}"
117+
;;
118+
esac
119+
120+
- name: React to PR summary message in slack with emoji
121+
if: ${{ steps.slack-timestamp.outputs.github_event_pull_request_html_url == 'true' && env.EMOJI != 'false' }}
122+
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
123+
with:
124+
method: reactions.add
125+
token: ${{ secrets.MY_SLACK_BOT_TOKEN }}
126+
payload: |
127+
channel: ${{ secrets.MY_SLACK_CHANNEL_ID }}
128+
timestamp: "${{ env.SLACK_TIMESTAMP }}"
129+
name: ${{ env.EMOJI }}
130+
131+
- name: Update the original message with status Merged ✅
132+
if: ${{ github.event.pull_request.merged && steps.slack-timestamp.outputs.github_event_pull_request_html_url == 'true' }}
133+
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
134+
with:
135+
method: chat.update
136+
token: ${{ secrets.MY_SLACK_BOT_TOKEN }}
137+
payload: |
138+
channel: ${{ secrets.MY_SLACK_CHANNEL_ID }}
139+
ts: "${{ env.SLACK_TIMESTAMP }}"
140+
text: "✅ *${{ github.event.pull_request.user.login }}*: <${{ github.event.repository.html_url }}|${{ github.repository }}> - <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}> (+${{ github.event.pull_request.additions }}, -${{ github.event.pull_request.deletions }})"
141+
attachments:
142+
- color: "28a745"
143+
fields:
144+
- title: "Status"
145+
short: true
146+
value: "Merged ✅"
147+
148+
- name: Update the original message with status Closed ❎
149+
if: ${{ github.event.action == 'closed' && github.event.pull_request.merged == false && steps.slack-timestamp.outputs.github_event_pull_request_html_url == 'true' }}
150+
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
151+
with:
152+
method: chat.update
153+
token: ${{ secrets.MY_SLACK_BOT_TOKEN }}
154+
payload: |
155+
channel: ${{ secrets.MY_SLACK_CHANNEL_ID }}
156+
ts: "${{ env.SLACK_TIMESTAMP }}"
157+
text: "❎ *${{ github.event.pull_request.user.login }}*: <${{ github.event.repository.html_url }}|${{ github.repository }}> - <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}> (+${{ github.event.pull_request.additions }}, -${{ github.event.pull_request.deletions }})"
158+
attachments:
159+
- color: "fa7015"
160+
fields:
161+
- title: "Status"
162+
short: true
163+
value: "Closed ❎"

.github/workflows/release-please.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ on:
77
branches:
88
- main
99

10-
permissions:
11-
contents: write
12-
pull-requests: write
10+
permissions: read-all
1311

1412
jobs:
1513
release-please:
1614
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
1718
steps:
18-
- uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 # v2.0.2
19+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
1920
id: app-token
2021
with:
2122
app-id: ${{ secrets.MY_RENOVATE_GITHUB_APP_ID }}

.github/workflows/renovate.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ env:
4343
permissions: read-all
4444

4545
jobs:
46+
github-context:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Debug
50+
env:
51+
GITHUB_CONTEXT: ${{ toJson(github) }}
52+
run: |
53+
echo "${GITHUB_CONTEXT}"
54+
4655
renovate:
4756
runs-on: ubuntu-latest
4857
concurrency:
@@ -52,13 +61,13 @@ jobs:
5261
- name: Checkout
5362
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5463

55-
- uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 # v2.0.2
64+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
5665
id: app-token
5766
with:
5867
app-id: ${{ secrets.MY_RENOVATE_GITHUB_APP_ID }}
5968
private-key: ${{ secrets.MY_RENOVATE_GITHUB_PRIVATE_KEY }}
6069

6170
- name: 💡 Self-hosted Renovate
62-
uses: renovatebot/github-action@67a664fc9b4481b33a3eff6ee9edfb7a7b9dfa1e # v41.0.2
71+
uses: renovatebot/github-action@19ba43e1bc58ed95c0ba205dee8b1bc0f27b630d # v42.0.0
6372
with:
6473
token: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)