diff --git a/.github/workflows/adev-preview-build.yml b/.github/workflows/adev-preview-build.yml new file mode 100644 index 000000000..ae63c6ca7 --- /dev/null +++ b/.github/workflows/adev-preview-build.yml @@ -0,0 +1,58 @@ +# This workflow builds the previews for pull requests when a certain label is applied. +# The actual deployment happens as part of a dedicated second workflow to avoid security +# issues where the building would otherwise occur in an authorized context where secrets +# could be leaked. More details can be found here: + +# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/. + +name: Build adev for preview deployment + +on: + pull_request: + types: [synchronize, labeled] + +permissions: read-all + +jobs: + adev-build: + runs-on: ubuntu-latest + if: | + (github.event.action == 'labeled' && github.event.label.name == 'adev: preview') || + (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'adev: preview')) + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-node@v4 + with: + node-version-file: '.node-version' + cache: yarn + - uses: bazel-contrib/setup-bazel@0.8.5 + with: + bazelisk-cache: true + disk-cache: true + repository-cache: true + bazelrc: | + # Print all the options that apply to the build. + # This helps us diagnose which options override others + # (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc) + build --announce_rc + + # More details on failures + build --verbose_failures=true + + # CI supports colors but Bazel does not detect it. + common --color=yes + - run: yarn install + - run: yarn build + - run: chmod 755 build/dist/bin/adev/build/browser + - name: Inject pull request number + run: echo "${{ github.event.pull_request.number }}" >> __metadata__pull_number.txt + working-directory: build/dist/bin/adev/build/browser + - name: Inject commit hash + run: echo "${{ github.sha }}" >> __metadata__commit_hash.txt + working-directory: build/dist/bin/adev/build/browser + - uses: actions/upload-artifact@v4 + with: + name: adev-preview + path: build/dist/bin/adev/build/browser diff --git a/.github/workflows/adev-preview-deploy.yml b/.github/workflows/adev-preview-deploy.yml new file mode 100644 index 000000000..2b42b8fed --- /dev/null +++ b/.github/workflows/adev-preview-deploy.yml @@ -0,0 +1,63 @@ +# This workflow runs whenever the ADEV build workflow has completed. Deployment happens +# as part of a dedicated second workflow to avoid security issues where the building would +# otherwise occur in an authorized context where secrets could be leaked. +# +# More details can be found here: +# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/. + +name: Deploying adev preview + +on: + workflow_run: + workflows: ['Build adev for preview deployment'] + types: [completed] + +permissions: + # Needed in order to be able to comment on the pull request. + pull-requests: write + # Needed in order to checkout the repository + contents: read + # Needed in order to retrieve the artifacts from the previous job + actions: read + +env: + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/download-artifact@v4 + with: + github-token: '${{secrets.GITHUB_TOKEN}}' + name: adev-preview + - run: ls -R + - name: Extract pull request number + run: | + PR_NUMBER=$(cat build/dist/bin/adev/build/browser/__metadata__pull_number.txt) + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + working-directory: build/dist/bin/adev/build/browser + - name: Extract commit hash + run: | + COMMIT_HASH=$(cat build/dist/bin/adev/build/browser/__metadata__commit_hash.txt) + echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV + working-directory: build/dist/bin/adev/build/browser + - run: echo $PR_NUMBER $COMMIT_HASH + - name: Deploy to cloudflare pages + run: npx wrangler publish ./ --project-name $CLOUDFLARE_PAGES_PROJECT --branch pr-$PR_NUMBER --commit-hash $COMMIT_HASH + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_PAGES_PROJECT: ${{ var.CLOUDFLARE_PAGES_PROJECT }} + - name: Comment on pull request + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const prNumber = process.env.PR_NUMBER; + github.issues.createComment({ + issue_number: Number(prNumber), + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Preview deployed to https://pr-${prNumber}.dev-angular-jp.pages.dev' + }) + diff --git a/.github/workflows/adev-production-deploy.yml b/.github/workflows/adev-production-deploy.yml new file mode 100644 index 000000000..f91b3f0d6 --- /dev/null +++ b/.github/workflows/adev-production-deploy.yml @@ -0,0 +1,45 @@ +name: Build adev and deploy to production + +on: + push: + branches: + - main + +env: + BAZEL_REPO_CACHE_PATH: '~/.cache/bazel_repo_cache' + +jobs: + adev-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-node@v4 + with: + node-version-file: '.node-version' + cache: yarn + - uses: bazel-contrib/setup-bazel@0.8.5 + with: + bazelisk-cache: true + disk-cache: true + repository-cache: true + bazelrc: | + # Print all the options that apply to the build. + # This helps us diagnose which options override others + # (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc) + build --announce_rc + + # More details on failures + build --verbose_failures=true + + # CI supports colors but Bazel does not detect it. + common --color=yes + - run: yarn install + - run: yarn build + - name: Deploy to cloudflare pages + run: npx wrangler pages deploy $OUTPUT_DIR --project-name $CLOUDFLARE_PAGES_PROJECT + env: + OUTPUT_DIR: build/dist/bin/adev/build/browser + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index edfb85cb8..cd87ce3c9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,19 +8,22 @@ on: [pull_request] permissions: contents: read +env: + BAZEL_REPO_CACHE_PATH: '~/.cache/bazel_repo_cache' + jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-node@v4 - with: - node-version-file: '.node-version' - cache: yarn - - run: yarn install - - run: yarn test + # test: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # submodules: true + # - uses: actions/setup-node@v4 + # with: + # node-version-file: '.node-version' + # cache: yarn + # - run: yarn install + # - run: yarn test build-ubuntu: runs-on: ubuntu-latest steps: @@ -31,6 +34,22 @@ jobs: with: node-version-file: '.node-version' cache: yarn + - uses: bazel-contrib/setup-bazel@0.8.5 + with: + bazelisk-cache: true + disk-cache: true + repository-cache: true + bazelrc: | + # Print all the options that apply to the build. + # This helps us diagnose which options override others + # (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc) + build --announce_rc + + # More details on failures + build --verbose_failures=true + + # CI supports colors but Bazel does not detect it. + common --color=yes - run: yarn install - run: yarn build # build-windows: @@ -46,15 +65,15 @@ jobs: # - run: yarn install # - run: yarn build # shell: pwsh - build-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-node@v4 - with: - node-version-file: '.node-version' - cache: yarn - - run: yarn install - - run: yarn build + # build-macos: + # runs-on: macos-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # submodules: true + # - uses: actions/setup-node@v4 + # with: + # node-version-file: '.node-version' + # cache: yarn + # - run: yarn install + # - run: yarn build diff --git a/origin b/origin index 27e693691..07a0b87a4 160000 --- a/origin +++ b/origin @@ -1 +1 @@ -Subproject commit 27e693691235f1971f8a4a631631fbca25834fed +Subproject commit 07a0b87a4c1e032c92d5596ce7a17b74a87e04e3 diff --git a/tools/adev-patches/change-analytics-id.patch b/tools/adev-patches/change-analytics-id.patch new file mode 100644 index 000000000..104086fd2 --- /dev/null +++ b/tools/adev-patches/change-analytics-id.patch @@ -0,0 +1,11 @@ +diff --git a/adev/src/app/environment.ts b/adev/src/app/environment.ts +index 30f0d78db3..c6c18b5183 100644 +--- a/adev/src/app/environment.ts ++++ b/adev/src/app/environment.ts +@@ -15,5 +15,5 @@ export default { + apiKey: 'dfca7ed184db27927a512e5c6668b968', + indexName: 'angular_v17', + }, +- googleAnalyticsId: 'G-XB6NEVW32B', ++ googleAnalyticsId: 'G-ZE76R447BW', + }; diff --git a/tools/adev-patches/change-document-title.patch b/tools/adev-patches/change-document-title.patch new file mode 100644 index 000000000..989e081d7 --- /dev/null +++ b/tools/adev-patches/change-document-title.patch @@ -0,0 +1,79 @@ +diff --git a/adev/src/app/core/services/a-dev-title-strategy.ts b/adev/src/app/core/services/a-dev-title-strategy.ts +index 75a1daa0e9..6acf3ec62f 100644 +--- a/adev/src/app/core/services/a-dev-title-strategy.ts ++++ b/adev/src/app/core/services/a-dev-title-strategy.ts +@@ -13,7 +13,7 @@ import {ActivatedRouteSnapshot, RouterStateSnapshot, TitleStrategy} from '@angul + + export const ROUTE_TITLE_PROPERTY = 'label'; + export const ROUTE_PARENT_PROPERTY = 'parent'; +-export const TITLE_SUFFIX = 'Angular'; ++export const TITLE_SUFFIX = 'Angular 日本語版'; + export const TITLE_SEPARATOR = ' • '; + export const DEFAULT_PAGE_TITLE = 'Overview'; + +diff --git a/adev/src/index.html b/adev/src/index.html +index f6d4c0eb48..292608d443 100644 +--- a/adev/src/index.html ++++ b/adev/src/index.html +@@ -1,6 +1,6 @@ + + +- ++ +
+