Skip to content

Commit 30b256a

Browse files
committed
Perm config for docker and tests workflows
1 parent 1da304a commit 30b256a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/workflows/docker.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,21 @@ jobs:
4747
run: |
4848
TAGS=""
4949
50+
# Convert repo name to lowercase for Docker Hub
51+
REPO_LOWER=$(echo "${{ env.REPO_NAME }}" | tr '[:upper:]' '[:lower:]')
52+
5053
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then
5154
# Manual dispatch with custom tag
5255
TAG="${{ inputs.tag }}"
53-
TAGS="docker.io/${{ env.REPO_NAME }}:${TAG},ghcr.io/${{ env.REPO_NAME }}:${TAG}"
56+
TAGS="docker.io/${REPO_LOWER}:${TAG},ghcr.io/${{ env.REPO_NAME }}:${TAG}"
5457
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
5558
# Git tag push
5659
TAG="${{ github.ref_name }}"
5760
TAG="${TAG#v}" # Remove v prefix
58-
TAGS="docker.io/${{ env.REPO_NAME }}:${TAG},ghcr.io/${{ env.REPO_NAME }}:${TAG}"
61+
TAGS="docker.io/${REPO_LOWER}:${TAG},ghcr.io/${{ env.REPO_NAME }}:${TAG}"
5962
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
6063
# Main branch push
61-
TAGS="docker.io/${{ env.REPO_NAME }}:latest,ghcr.io/${{ env.REPO_NAME }}:latest"
64+
TAGS="docker.io/${REPO_LOWER}:latest,ghcr.io/${{ env.REPO_NAME }}:latest"
6265
fi
6366
6467
echo "tags=${TAGS}" >> $GITHUB_OUTPUT

.github/workflows/tests.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: 🧪 Run Tests
22

33
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
46
pull_request_target:
57
types: [opened, synchronize, reopened]
68
push:
@@ -18,8 +20,8 @@ permissions:
1820

1921
env:
2022
# PR context helpers for conditional logic
21-
IS_PR: ${{ github.event_name == 'pull_request_target' }}
22-
IS_FORK: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository }}
23+
IS_PR: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
24+
IS_FORK: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.repo.full_name != github.repository }}
2325
HAS_BOT_TOKEN: ${{ secrets.BOT_TOKEN != '' }}
2426

2527
jobs:
@@ -33,7 +35,7 @@ jobs:
3335
# Secure checkout for external PRs
3436
- uses: actions/checkout@v4
3537
with:
36-
# For PRs from forks, check out the PR head to prevent token exposure
38+
# For PRs from forks via pull_request_target, check out the PR head to prevent token exposure
3739
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
3840

3941
- uses: actions/setup-node@v4
@@ -65,7 +67,7 @@ jobs:
6567
path: test-result-unit.txt
6668

6769
- name: Upload coverage to Codecov
68-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
70+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (env.IS_PR == 'true' && env.IS_FORK != 'true')
6971
uses: codecov/codecov-action@v4
7072
with:
7173
token: ${{ secrets.CODECOV_TOKEN }}
@@ -123,7 +125,7 @@ jobs:
123125
# Secure checkout for external PRs
124126
- uses: actions/checkout@v4
125127
with:
126-
# For PRs from forks, check out the PR head to prevent naughty people finding my token
128+
# For PRs from forks via pull_request_target, check out the PR head to prevent token exposure
127129
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
128130

129131
- uses: actions/setup-node@v4
@@ -201,7 +203,7 @@ jobs:
201203
# Secure checkout for external PRs
202204
- uses: actions/checkout@v4
203205
with:
204-
# For PRs from forks, check out the PR head to prevent token exposure
206+
# For PRs from forks via pull_request_target, check out the PR head to prevent token exposure
205207
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
206208

207209
- uses: actions/setup-node@v4

0 commit comments

Comments
 (0)