Skip to content

Commit b96733c

Browse files
workflows: swap softprops for gh CLI, add CloudFront reachability check, remove --acl
Three follow-up corrections to PR #17: 1. Remove `--acl public-read` from `aws s3 cp`. The bucket has `disable_confusing_acls = true` (BucketOwnerEnforced), which disables ACLs entirely. `BlockPublicAcls` + `IgnorePublicAcls` provide additional coverage. The ACL flag is silently ignored. The IAM role (`S3_ACCESS_MODE.PUT`) also doesn't grant `PutObjectAcl`. Reads go via CloudFront OAC, not public-S3. 2. Replace `softprops/action-gh-release` with GitHub's first-party `gh` CLI. `gh release upload` is pre-installed on GitHub-hosted runners, removes a third-party (single-maintainer) supply-chain dependency, and behaves equivalently with `--clobber`. 3. Add a post-upload CloudFront reachability check (`curl -fI`). If the CloudFront path_patterns allowlist doesn't include the key's prefix, Mac Bazel builds will silently 403. Failing the workflow here surfaces the issue before consumers hit it. S3 path stays `node-gyp/*` (this PR no longer changes it — see codez PR #390222 which adds `node-gyp/*` to CloudFront's path_patterns in system_packages.tf). Action pinning: tag-pinned per codez convention (100% of codez workflows use tags, not SHAs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 104256b commit b96733c

2 files changed

Lines changed: 39 additions & 8 deletions

File tree

.github/workflows/build-node-packages.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ jobs:
7373
tar --hard-dereference -cvzf packages_${{matrix.arch}}.tar.gz bcrypt@5.1.0 cld@2.9.1 unix-dgram@2.0.6 "@datadog+pprof@5.8.0"
7474
7575
- name: Upload archive to release
76-
uses: softprops/action-gh-release@v1
77-
with:
78-
name: node-${{ env.NODE_VERSION }}-LATEST
79-
tag_name: node-${{ env.NODE_VERSION }}-release
80-
files: packages_${{matrix.arch}}.tar.gz
76+
# Use `gh release upload` (first-party GitHub CLI, pre-installed on runners)
77+
# instead of softprops/action-gh-release (one-maintainer third-party action).
78+
# Behavior: --clobber overwrites an existing asset with the same name, matching
79+
# softprops's default. The release must already exist (created by build-node.yml).
8180
env:
8281
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
gh release upload "node-${{ env.NODE_VERSION }}-release" \
84+
"packages_${{ matrix.arch }}.tar.gz" \
85+
--clobber \
86+
--repo "${{ github.repository }}"
8387
8488
# S3 upload is restricted to the protected main branch only. The IAM role
8589
# (push_node_gyp_packages) trusts only refs/heads/main via OIDC. To upload
@@ -94,12 +98,38 @@ jobs:
9498
- name: Upload packages to S3
9599
if: github.ref == 'refs/heads/main'
96100
run: |
101+
# Upload to s3://asana-oss-cache/node-gyp/... (CloudFront path_patterns entry
102+
# added in codez PR #390222 — that must be merged + applied via Spacelift
103+
# before this workflow can successfully publish fetchable objects).
104+
#
105+
# No --acl public-read: the bucket has BucketOwnerEnforced
106+
# (disable_confusing_acls = true), which disables ACLs entirely.
107+
# BlockPublicAcls + IgnorePublicAcls provide additional coverage.
108+
# Reads come via CloudFront OAC.
97109
NODE_MAJOR=$(echo "${{ env.NODE_VERSION }}" | sed 's/^v//' | cut -d. -f1)
98110
SHA256=$(sha256sum "packages_${{ matrix.arch }}.tar.gz" | awk '{print $1}')
99111
SHORT_HASH=${SHA256:0:8}
100112
S3_KEY="node-gyp/packages_${{ matrix.bazel_arch }}_node${NODE_MAJOR}-${SHORT_HASH}.tar.gz"
101113
echo "Uploading packages_${{ matrix.arch }}.tar.gz to s3://asana-oss-cache/${S3_KEY}"
102-
aws s3 cp "packages_${{ matrix.arch }}.tar.gz" "s3://asana-oss-cache/${S3_KEY}" --acl public-read
114+
aws s3 cp "packages_${{ matrix.arch }}.tar.gz" "s3://asana-oss-cache/${S3_KEY}"
115+
echo "S3_KEY=${S3_KEY}" >> "$GITHUB_ENV"
116+
echo "SHA256=${SHA256}" >> "$GITHUB_ENV"
117+
echo "NODE_MAJOR=${NODE_MAJOR}" >> "$GITHUB_ENV"
118+
119+
- name: Verify upload is reachable via CloudFront
120+
if: github.ref == 'refs/heads/main'
121+
run: |
122+
# Mac Bazel builds rewrite asana-oss-cache.s3.us-east-1.amazonaws.com/*
123+
# to asana-oss-cache.asana.biz/* (CloudFront). If the S3 key prefix isn't
124+
# allowlisted in CloudFront's path_patterns, Bazel fetches will 403.
125+
# Fail fast here rather than after someone tries to build.
126+
URL="https://asana-oss-cache.asana.biz/${S3_KEY}"
127+
echo "Checking ${URL}"
128+
curl -fsSI "${URL}" || { echo "CloudFront returned an error for ${URL}. Check path_patterns in system_packages.tf."; exit 1; }
129+
130+
- name: Print tools_repositories.bzl stanza
131+
if: github.ref == 'refs/heads/main'
132+
run: |
103133
echo ""
104134
echo "=== Update tools_repositories.bzl in codez ==="
105135
echo " name = \"node_gyp_packages_${{ matrix.bazel_arch }}_node${NODE_MAJOR}\","

stage_for_s3.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ gh release download -p "*.xz"
1616
echo ""
1717
echo "=== Native packages (node-gyp) ==="
1818
echo "These are uploaded to s3://asana-oss-cache/node-gyp/ by the build-node-packages.yml workflow"
19-
echo "with content-hashed S3 keys. Each build produces an immutable artifact."
19+
echo "(triggered via workflow_dispatch from main) with content-hashed S3 keys."
20+
echo "Each build produces an immutable artifact."
2021
for pkg in packages_*.tar.gz; do
2122
if [ -f "$pkg" ]; then
2223
echo " $pkg: sha256=$(sha256sum "$pkg" | awk '{print $1}')"
2324
rm "$pkg"
2425
fi
2526
done
26-
echo "No manual action needed for packages — they are already in S3."
27+
echo "No manual action needed for packages if you've already dispatched build-node-packages.yml from main."
2728
echo ""
2829

2930
curl "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz

0 commit comments

Comments
 (0)