Skip to content

Commit 83d650f

Browse files
chore(actions): Replace unverified actions with GH scripts (#4604)
* chore(actions): Replace unverified actions with GH scripts * chore(actions): Update rust toolchain in Dockerfile
1 parent a8ae674 commit 83d650f

File tree

6 files changed

+81
-21
lines changed

6 files changed

+81
-21
lines changed

.github/workflows/kotlin-ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ jobs:
2323
java-version: '17'
2424
distribution: 'temurin'
2525

26-
- name: Setup Android SDK
27-
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
28-
2926
- name: Setup Gradle
3027
uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0
3128
with:

.github/workflows/kotlin-sample-ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ jobs:
2323
java-version: '17'
2424
distribution: 'temurin'
2525

26-
- name: Setup Android SDK
27-
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
28-
2926
- name: Install Kotlin Dependencies
3027
run: tools/install-kotlin-dependencies
3128

.github/workflows/rust.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,13 @@ jobs:
126126
# Download previous release report, compare the release binary sizes, and post/update a comment at the Pull Request.
127127
- name: Download previous release report
128128
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
129-
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6
130-
with:
131-
commit: ${{github.event.pull_request.base.sha}}
132-
path: previous
133-
if_no_artifact_found: warn
129+
run: ./tools/gh-download-workflow-artifact
130+
env:
131+
COMMIT: ${{github.event.pull_request.base.sha}}
132+
DOWNLOAD_PATH: previous
134133
# Same artifact name as at the "Upload release report" step.
135-
name: release_report
136-
# Ignore status or conclusion in the search.
137-
workflow_conclusion: ""
134+
ARTIFACT_NAME: release_report
135+
GH_TOKEN: ${{ github.token }}
138136

139137
- name: Craft Comment Body
140138
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
@@ -144,13 +142,11 @@ jobs:
144142
145143
- name: Create or Update Comment
146144
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
147-
uses: edumserrano/find-create-or-update-comment@3d340543af6d2743c70ab2d525deeb0f12e290de # v2.0.0
145+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
148146
with:
149-
issue-number: ${{ github.event.pull_request.number }}
150-
body-includes: "Binary size comparison"
151-
comment-author: 'github-actions[bot]'
152-
edit-mode: replace
153-
body-path: 'report-diff.md'
147+
script: |
148+
const script = require('./tools/gh-create-or-update-comment.js');
149+
await script({github, context, bodyPath: 'report-diff.md', bodyIncludes: 'Binary size comparison'});
154150
155151
memory-profiler:
156152
runs-on: ubuntu-24.04

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ RUN ln -s /usr/bin/clang++-14 /usr/bin/clang++
4242
RUN wget "https://sh.rustup.rs" -O rustup.sh \
4343
&& sh rustup.sh -y
4444
ENV PATH="/root/.cargo/bin:${PATH}"
45-
RUN rustup default nightly-2024-06-13
45+
RUN rustup default nightly-2025-12-11
4646
RUN cargo install --force cbindgen --locked \
4747
&& rustup target add wasm32-unknown-emscripten
4848

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const fs = require('fs');
2+
3+
module.exports = async ({github, context, bodyPath, bodyIncludes}) => {
4+
const body = fs.readFileSync(bodyPath, 'utf8');
5+
6+
// Find existing comment
7+
const { data: comments } = await github.rest.issues.listComments({
8+
owner: context.repo.owner,
9+
repo: context.repo.repo,
10+
issue_number: context.issue.number
11+
});
12+
13+
const botComment = comments.find(comment =>
14+
comment.user.login === 'github-actions[bot]' &&
15+
comment.body.includes(bodyIncludes)
16+
);
17+
18+
// Create or update comment
19+
if (botComment) {
20+
await github.rest.issues.updateComment({
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
comment_id: botComment.id,
24+
body: body
25+
});
26+
console.log(`Updated comment ${botComment.id}`);
27+
} else {
28+
const { data: newComment } = await github.rest.issues.createComment({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
issue_number: context.issue.number,
32+
body: body
33+
});
34+
console.log(`Created comment ${newComment.id}`);
35+
}
36+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
COMMIT="${COMMIT:?COMMIT environment variable is required}"
5+
DOWNLOAD_PATH="${DOWNLOAD_PATH:?DOWNLOAD_PATH environment variable is required}"
6+
ARTIFACT_NAME="${ARTIFACT_NAME:?ARTIFACT_NAME environment variable is required}"
7+
8+
echo "Searching for artifact '$ARTIFACT_NAME' from commit $COMMIT..."
9+
10+
# Find the artifact ID
11+
ARTIFACT_ID=$(gh api \
12+
"repos/$GITHUB_REPOSITORY/actions/artifacts" \
13+
--jq ".artifacts[] | select(.workflow_run.head_sha == \"$COMMIT\" and .name == \"$ARTIFACT_NAME\" and .expired == false) | .id" \
14+
| head -n 1)
15+
16+
if [ -z "$ARTIFACT_ID" ]; then
17+
echo "Warning: No artifact found for commit $COMMIT with name '$ARTIFACT_NAME'"
18+
exit 0
19+
fi
20+
21+
echo "Found artifact ID: $ARTIFACT_ID"
22+
23+
# Create download directory
24+
mkdir -p "$DOWNLOAD_PATH"
25+
26+
# Download and extract artifact
27+
echo "Downloading artifact..."
28+
gh api "repos/$GITHUB_REPOSITORY/actions/artifacts/$ARTIFACT_ID/zip" > /tmp/artifact.zip
29+
30+
echo "Extracting to $DOWNLOAD_PATH..."
31+
unzip -q /tmp/artifact.zip -d "$DOWNLOAD_PATH"
32+
rm /tmp/artifact.zip
33+
34+
echo "Successfully downloaded artifact to $DOWNLOAD_PATH"

0 commit comments

Comments
 (0)