Skip to content

Commit 22846ef

Browse files
Fix node-gyp S3 path, swap softprops for gh CLI, add CloudFront reachability check
Several follow-up corrections to PR #17: 1. Move S3 upload from `node-gyp/*` to `node/gyp/*`. The `asana-oss-cache` bucket is BlockPublicAccess-enabled, so Mac dev laptops read via CloudFront (asana-oss-cache.asana.biz, per the Bazel URL rewriter in tools/bzl/config/external_bazel_downloader.cfg). CloudFront only serves paths listed in `path_patterns` (terraform/general/buildinfra/system_packages.tf), which includes `node/*` but NOT `node-gyp/*`. The previous path would have 403'd on every Mac Bazel build. Nesting under `node/*` reuses the existing allowlisted prefix. 2. Remove `--acl public-read` from `aws s3 cp`. The bucket has `BlockPublicAcls: true` AND `IgnorePublicAcls: true` — the ACL is silently dropped. The IAM role (S3_ACCESS_MODE.PUT) doesn't grant PutObjectAcl either. Reads go via CloudFront anyway, so the flag is misleading dead code. 3. 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 supply-chain dependency, and behaves equivalently (with --clobber). 4. Add a post-upload CloudFront reachability check (`curl -fI`). If the S3 key prefix ever falls outside CloudFront's path_patterns, Mac builds will silently 403. Failing the workflow here surfaces the issue before consumers hit it. 5. Update stage_for_s3.bash's echo text to match the new S3 path and clarify that workflow_dispatch from main is required. 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 22846ef

2 files changed

Lines changed: 40 additions & 10 deletions

File tree

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

Lines changed: 36 additions & 7 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,37 @@ 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/... (under the `node/*` CloudFront
102+
# path_patterns prefix in asana2/asana/tools/terraform/general/buildinfra/system_packages.tf).
103+
# Using a bare `node-gyp/*` key would not be served by CloudFront, and Mac
104+
# Bazel builds rewrite direct S3 URLs to CloudFront, so they'd 403.
105+
#
106+
# No --acl public-read: the bucket has BlockPublicAcls + IgnorePublicAcls,
107+
# and the IAM role doesn't grant PutObjectAcl. Reads come via CloudFront.
97108
NODE_MAJOR=$(echo "${{ env.NODE_VERSION }}" | sed 's/^v//' | cut -d. -f1)
98109
SHA256=$(sha256sum "packages_${{ matrix.arch }}.tar.gz" | awk '{print $1}')
99110
SHORT_HASH=${SHA256:0:8}
100-
S3_KEY="node-gyp/packages_${{ matrix.bazel_arch }}_node${NODE_MAJOR}-${SHORT_HASH}.tar.gz"
111+
S3_KEY="node/gyp/packages_${{ matrix.bazel_arch }}_node${NODE_MAJOR}-${SHORT_HASH}.tar.gz"
101112
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
113+
aws s3 cp "packages_${{ matrix.arch }}.tar.gz" "s3://asana-oss-cache/${S3_KEY}"
114+
echo "S3_KEY=${S3_KEY}" >> "$GITHUB_ENV"
115+
echo "SHA256=${SHA256}" >> "$GITHUB_ENV"
116+
echo "NODE_MAJOR=${NODE_MAJOR}" >> "$GITHUB_ENV"
117+
118+
- name: Verify upload is reachable via CloudFront
119+
if: github.ref == 'refs/heads/main'
120+
run: |
121+
# Mac Bazel builds rewrite asana-oss-cache.s3.us-east-1.amazonaws.com/*
122+
# to asana-oss-cache.asana.biz/* (CloudFront). If the S3 key prefix isn't
123+
# allowlisted in CloudFront's path_patterns, Bazel fetches will 403.
124+
# Fail fast here rather than after someone tries to build.
125+
URL="https://asana-oss-cache.asana.biz/${S3_KEY}"
126+
echo "Checking ${URL}"
127+
curl -fsSI "${URL}" || { echo "CloudFront returned an error for ${URL}. Check path_patterns in system_packages.tf."; exit 1; }
128+
129+
- name: Print tools_repositories.bzl stanza
130+
if: github.ref == 'refs/heads/main'
131+
run: |
103132
echo ""
104133
echo "=== Update tools_repositories.bzl in codez ==="
105134
echo " name = \"node_gyp_packages_${{ matrix.bazel_arch }}_node${NODE_MAJOR}\","

stage_for_s3.bash

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ gh release download -p "*.xz"
1515
# consumed by Bazel via http_file in codez. They should NOT be mixed into the fibers archive.
1616
echo ""
1717
echo "=== Native packages (node-gyp) ==="
18-
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."
18+
echo "These are uploaded to s3://asana-oss-cache/node/gyp/ by the build-node-packages.yml workflow"
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)