Skip to content

Commit 9738e0f

Browse files
Potential fix for code scanning alert no. 1: Code injection
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 723d9a6 commit 9738e0f

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

.github/workflows/update-homebrew-cask.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@ jobs:
2828
steps:
2929
- name: Extract version from workflow run
3030
id: version
31+
env:
32+
EVENT_NAME: ${{ github.event_name }}
33+
INPUT_VERSION: ${{ github.event.inputs.version }}
34+
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
3135
run: |
32-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
33-
VERSION="${{ github.event.inputs.version }}"
36+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
37+
VERSION="$INPUT_VERSION"
3438
else
3539
# Get the tag from the workflow run
3640
# The release workflow runs on tag push, so we extract from head_branch
37-
VERSION="${{ github.event.workflow_run.head_branch }}"
41+
VERSION="$HEAD_BRANCH"
3842
fi
39-
echo "version=$VERSION" >> $GITHUB_OUTPUT
43+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4044
echo "Release version: $VERSION"
4145
4246
- name: Get DMG asset details
@@ -79,16 +83,16 @@ jobs:
7983
uses: actions/checkout@v4
8084
with:
8185
repository: SyntheticAutonomicMind/homebrew-SAM
86+
env:
87+
VERSION: ${{ steps.version.outputs.version }}
88+
SHA256: ${{ steps.hash.outputs.sha256 }}
89+
DMG_URL: ${{ steps.asset.outputs.url }}
8290
token: ${{ secrets.HOMEBREW_PAT }}
8391
path: homebrew
8492

8593
- name: Update SAM cask
8694
working-directory: homebrew
8795
run: |
88-
VERSION="${{ steps.version.outputs.version }}"
89-
SHA256="${{ steps.hash.outputs.sha256 }}"
90-
DMG_URL="${{ steps.asset.outputs.url }}"
91-
9296
echo "Updating Casks/sam.rb"
9397
echo " Version: $VERSION"
9498
echo " SHA256: $SHA256"
@@ -99,6 +103,8 @@ jobs:
99103
-e "s|sha256 \"[^\"]*\"|sha256 \"$SHA256\"|" \
100104
Casks/sam.rb
101105
106+
env:
107+
VERSION: ${{ steps.version.outputs.version }}
102108
# Show the updated file
103109
echo "Updated Casks/sam.rb:"
104110
head -10 Casks/sam.rb
@@ -109,8 +115,6 @@ jobs:
109115
git config user.name "github-actions[bot]"
110116
git config user.email "github-actions[bot]@users.noreply.github.com"
111117
112-
VERSION="${{ steps.version.outputs.version }}"
113-
114118
git add Casks/sam.rb
115119
if git diff --staged --quiet; then
116120
echo "No changes detected"

0 commit comments

Comments
 (0)