Skip to content

Commit

Permalink
chore: add initial workflow for adev build (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
lacolaco authored Jul 13, 2024
1 parent a394bc9 commit fa83b76
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 51 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/adev-preview-build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
63 changes: 63 additions & 0 deletions .github/workflows/adev-preview-deploy.yml
Original file line number Diff line number Diff line change
@@ -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'
})
45 changes: 45 additions & 0 deletions .github/workflows/adev-production-deploy.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
67 changes: 43 additions & 24 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,6 +34,22 @@ jobs:
with:
node-version-file: '.node-version'
cache: yarn
- uses: bazel-contrib/[email protected]
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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion origin
Submodule origin updated 7822 files
11 changes: 11 additions & 0 deletions tools/adev-patches/change-analytics-id.patch
Original file line number Diff line number Diff line change
@@ -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',
};
79 changes: 79 additions & 0 deletions tools/adev-patches/change-document-title.patch
Original file line number Diff line number Diff line change
@@ -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 @@
<!doctype html>
<!-- We set all theme classes to allow critters to inline the theme styles and prevent flickering -->
-<html lang="en" class="docs-dark-mode docs-light-mode">
+<html lang="ja" class="docs-dark-mode docs-light-mode">
<head>
<script>
// This logic must execute early, so that we set the necessary
@@ -42,13 +42,13 @@
</style>

<meta charset="utf-8" />
- <title>Angular</title>
+ <title>Angular 日本語版</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!-- Primary Meta Tags -->
- <meta name="title" content="Angular" />
- <meta name="description" content="The web development framework for building modern apps." />
+ <meta name="title" content="Angular 日本語版" />
+ <meta name="description" content="モダンなアプリを構築するためのウェブ開発フレームワーク" />

<!-- Favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
@@ -58,7 +58,7 @@
<link rel="manifest" href="/assets/icons/site.webmanifest" />
<link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#e90464" />
<link rel="shortcut icon" href="/assets/icons/favicon.ico" />
- <link rel="canonical" href="https://angular.dev">
+ <link rel="canonical" href="https://angular.jp">

<meta name="apple-mobile-web-app-title" content="Angular" />
<meta name="application-name" content="Angular" />
@@ -68,21 +68,21 @@

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
- <meta property="og:url" content="https://angular.dev/" />
- <meta property="og:title" content="Angular" />
+ <meta property="og:url" content="https://angular.jp/" />
+ <meta property="og:title" content="Angular 日本語版" />
<meta
property="og:description"
- content="The web development framework for building modern apps."
+ content="モダンなアプリを構築するためのウェブ開発フレームワーク"
/>
<meta property="og:image" content="https://angular.dev/assets/images/ng-image.jpg" />

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
- <meta property="twitter:url" content="https://angular.dev/" />
- <meta property="twitter:title" content="Angular" />
+ <meta property="twitter:url" content="https://angular.jp/" />
+ <meta property="twitter:title" content="Angular 日本語版" />
<meta
property="twitter:description"
- content="The web development framework for building modern apps."
+ content="モダンなアプリを構築するためのウェブ開発フレームワーク"
/>
<meta property="twitter:image" content="https://angular.dev/assets/images/ng-image.jpg" />

Loading

0 comments on commit fa83b76

Please sign in to comment.