Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve security of GitHub Actions workflows #2510

Merged
merged 47 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5444909
a
KevinEyo1 Jan 29, 2024
a4a4d72
Revert test changes
KevinEyo1 Jan 29, 2024
ea3aca7
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 4, 2024
c0f79a2
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 9, 2024
45b8846
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 18, 2024
21628f7
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 28, 2024
969865f
Add how to check if permissions are given
yucheng11122017 Mar 12, 2024
46397e7
Merge branch 'master' of https://github.com/MarkBind/markbind
yucheng11122017 Mar 14, 2024
21fa90c
Merge branch 'master' of https://github.com/KevinEyo1/markbind
KevinEyo1 Mar 15, 2024
0bc66f7
Merge branch 'master' of https://github.com/MarkBind/markbind
yucheng11122017 Mar 17, 2024
0ebb7cd
Merge branch 'MarkBind:master' into master
KevinEyo1 Mar 18, 2024
f798b1d
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 20, 2024
48399bd
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 20, 2024
cb84513
Fix merge conflict
yucheng11122017 Mar 23, 2024
701183b
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 25, 2024
4a83981
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 29, 2024
7e7cfb7
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 29, 2024
57a9f9a
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 31, 2024
4730eba
add stuff
Apr 1, 2024
5c8bcfe
kevin
Apr 1, 2024
64819db
Merge pull request #32 from leongdl135/master
KevinEyo1 Apr 2, 2024
e2f6301
Allocate space for scrollbar in nav components
jingting1412 Apr 5, 2024
eb69423
Fix merge conflict
yucheng11122017 Apr 5, 2024
936dadc
Fix merge conflict
yucheng11122017 Apr 5, 2024
5b9e7d7
Revert "Fix merge conflict"
yucheng11122017 Apr 5, 2024
77a6a80
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Apr 5, 2024
2873a6e
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Apr 6, 2024
012ac3a
Merge branch 'MarkBind:master' into master
KevinEyo1 Apr 6, 2024
f8c0d97
Merge branch 'master' of https://github.com/KevinEyo1/markbind
KevinEyo1 Apr 6, 2024
3814f15
Fix code
KevinEyo1 Apr 6, 2024
89de762
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Apr 8, 2024
45cf23b
Refactor code and improve security
KevinEyo1 Apr 9, 2024
21d35aa
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Apr 9, 2024
2897dd7
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 9, 2024
a69a1df
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 9, 2024
917e6a0
Merge branch '2488-improve-sec' of https://github.com/KevinEyo1/markb…
KevinEyo1 Apr 9, 2024
39a3090
Remove change
KevinEyo1 Apr 9, 2024
b5262ba
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 10, 2024
6b3739f
Add dependabot file
KevinEyo1 Apr 10, 2024
243fc65
Merge branch '2488-improve-sec' of https://github.com/KevinEyo1/markb…
KevinEyo1 Apr 10, 2024
1dcc772
Revert to version number
KevinEyo1 Apr 11, 2024
8b185c3
Remove line
KevinEyo1 Apr 11, 2024
a1d2855
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 11, 2024
ed532e1
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 11, 2024
42a25a5
Update .github/workflows/pr-merge.yml
KevinEyo1 Apr 12, 2024
c4e8eca
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 12, 2024
b199f86
Merge branch 'master' into 2488-improve-sec
KevinEyo1 Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,40 @@ jobs:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
permissions:
contents: read

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
yucheng11122017 marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7
with:
node-version: '16'
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
uses: tlylt/install-graphviz@b2201200d85f06f0189cb74d9b69208504cf12cd
- name: Install Java
uses: actions/setup-java@v3
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: '11'
distribution: 'temurin'
- run: npm run setup
- run: npm run test
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
check-docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7
with:
node-version: '16'
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
uses: tlylt/install-graphviz@b2201200d85f06f0189cb74d9b69208504cf12cd
- name: Install Java
uses: actions/setup-java@v3
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: '11'
distribution: 'temurin'
Expand All @@ -69,18 +73,17 @@ jobs:
# disabled on forks
if: github.event_name == 'push' && github.repository == 'MarkBind/markbind'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7
with:
node-version: '16'
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
uses: tlylt/install-graphviz@b2201200d85f06f0189cb74d9b69208504cf12cd
- name: Install Java
uses: actions/setup-java@v3
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: '11'
distribution: 'temurin'
Expand Down
63 changes: 39 additions & 24 deletions .github/workflows/pr-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ jobs:
check-pr-label:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
num_labels_chosen: ${{ steps.check_pr_description_label.outputs.num_labels_chosen }}
message: ${{ steps.check_pr_description_label.outputs.message }}
chosen_label: ${{ steps.check_pr_description_label.outputs.chosen_label }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744

- name: Check for PR description label
id: check_pr_description_label
run: |
Expand All @@ -24,13 +31,13 @@ jobs:
is_minor=$(echo "$proposed_version_impact" | grep -qi '\[X\] Minor'; echo $((1-$?)))
is_patch=$(echo "$proposed_version_impact" | grep -qi '\[X\] Patch'; echo $((1-$?)))
num_labels_chosen=$(($is_major + $is_minor + $is_patch))
echo "num_labels_chosen=$num_labels_chosen" >> $GITHUB_OUTPUT
echo "num_labels_chosen=$num_labels_chosen" >> "$GITHUB_OUTPUT"
if [[ "$num_labels_chosen" -eq 0 ]]; then
echo "message=$(echo "@${MERGE_AUTHOR} Each PR must have a SEMVER impact label, please remember to label the PR properly.")" >> $GITHUB_OUTPUT
echo "message=$(echo "@${MERGE_AUTHOR} Each PR must have a SEMVER impact label, please remember to label the PR properly.")" >> "$GITHUB_OUTPUT"
elif [[ "$num_labels_chosen" -ge 2 ]]; then
echo "message=$(echo "@${MERGE_AUTHOR} Each PR can only have one SEMVER impact label, please remember to label the PR properly.")" >> $GITHUB_OUTPUT
echo "message=$(echo "@${MERGE_AUTHOR} Each PR can only have one SEMVER impact label, please remember to label the PR properly.")" >> "$GITHUB_OUTPUT"
else
echo "message=$(echo "SEMVER impact selected.")" >> $GITHUB_OUTPUT
echo "message=$(echo "SEMVER impact selected.")" >> "$GITHUB_OUTPUT"
echo "chosen_label=$(
if [ "$is_major" -eq 1 ]; then
echo "r.Major"
Expand All @@ -39,31 +46,39 @@ jobs:
elif [ "$is_patch" -eq 1 ]; then
echo "r.Patch"
fi
)" >> $GITHUB_OUTPUT
)" >> "$GITHUB_OUTPUT"
fi
env:
TEXT_BODY: ${{ github.event.pull_request.body }}
MERGE_AUTHOR: ${{ github.event.sender.login }}
- name: Assign label based on version impact
uses: actions/github-script@v7

assign-label-or-comment:
KevinEyo1 marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
needs: check-pr-label
permissions:
pull-requests: write
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
if (process.env.NUM_LABELS_CHOSEN != 1) {
github.rest.issues.createComment({
script: |
if (process.env.NUM_LABELS_CHOSEN != 1) {
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.MESSAGE,
});
} else {
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.MESSAGE,
});
} else {
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [process.env.CHOSEN_LABEL]
});
}
labels: [process.env.CHOSEN_LABEL]
});
}
env:
NUM_LABELS_CHOSEN: ${{ steps.check_pr_description_label.outputs.num_labels_chosen }}
MESSAGE: ${{ steps.check_pr_description_label.outputs.message }}
CHOSEN_LABEL: ${{ steps.check_pr_description_label.outputs.chosen_label }}
NUM_LABELS_CHOSEN: ${{ needs.check-pr-label.outputs.num_labels_chosen }}
MESSAGE: ${{ needs.check-pr-label.outputs.message }}
CHOSEN_LABEL: ${{ needs.check-pr-label.outputs.chosen_label }}

4 changes: 3 additions & 1 deletion .github/workflows/pr-message-reminder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
remind-pr-author:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Extract Proposed Commit Message
run: |
python scripts/process_message.py "${TEXT_BODY}" > processed_body.txt
Expand Down
Loading