Skip to content

Commit fce169d

Browse files
Update google-cloudrun-docker.yml
1 parent 26873ff commit fce169d

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

.github/workflows/google-cloudrun-docker.yml

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,77 @@ name: Deploy Angular Blog to Cloud Run
33
on:
44
push:
55
branches:
6-
- main
6+
- main
77

88
jobs:
99
test:
10-
name: Run Unit Tests
1110
runs-on: ubuntu-latest
1211
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v3
12+
- uses: actions/checkout@v3
1513

16-
- name: Set up Node.js
17-
uses: actions/setup-node@v3
14+
- uses: actions/setup-node@v3
1815
with:
1916
node-version: '18'
20-
- name: Generate environment.ts from secrets
21-
shell: bash
17+
18+
- name: Generate Angular environment files
2219
run: |
23-
cat > src/environments/environment.ts <<'EOF'
20+
cat <<EOF > src/environments/environment.ts
21+
export const environment = {
22+
production: false,
23+
supabaseUrl: '${SUPABASE_URL}',
24+
supabaseKey: '${SUPABASE_ANON_KEY}',
25+
};
26+
EOF
27+
cat <<EOF > src/environments/environment.prod.ts
2428
export const environment = {
2529
production: true,
26-
supabaseUrl: '${{ secrets.SUPABASE_URL }}',
27-
supabaseKey: '${{ secrets.SUPABASE_ANON_KEY }}',
30+
supabaseUrl: '${SUPABASE_URL}',
31+
supabaseKey: '${SUPABASE_ANON_KEY}',
2832
};
2933
EOF
34+
env:
35+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
36+
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
3037

31-
- name: Install dependencies
32-
run: npm ci
38+
- run: npm ci
3339

34-
- name: Run unit tests with headless Chrome
35-
run: npm run test -- --browsers=ChromeHeadless --watch=false --no-progress
36-
continue-on-error: false
40+
- run: npm run test -- --browsers=ChromeHeadless --watch=false --no-progress
3741

3842
deploy:
39-
name: Build and Deploy
4043
runs-on: ubuntu-latest
4144
needs: test
42-
4345
steps:
44-
- name: Checkout code
45-
uses: actions/checkout@v3
46+
- uses: actions/checkout@v3
4647

47-
- name: Set up Node.js
48-
uses: actions/setup-node@v3
48+
- uses: actions/setup-node@v3
4949
with:
5050
node-version: '18'
5151

52-
- name: Install dependencies
53-
run: npm ci
52+
- name: Generate Angular environment files
53+
run: |
54+
cat <<EOF > src/environments/environment.ts
55+
export const environment = {
56+
production: false,
57+
supabaseUrl: '${SUPABASE_URL}',
58+
supabaseKey: '${SUPABASE_ANON_KEY}',
59+
};
60+
EOF
61+
cat <<EOF > src/environments/environment.prod.ts
62+
export const environment = {
63+
production: true,
64+
supabaseUrl: '${SUPABASE_URL}',
65+
supabaseKey: '${SUPABASE_ANON_KEY}',
66+
};
67+
EOF
68+
env:
69+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
70+
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
71+
72+
- run: npm ci
5473

55-
- name: Build Angular app
56-
run: npm run build --prod
74+
- run: npm run build --prod
5775

58-
- name: Authenticate to Google Cloud
59-
uses: google-github-actions/auth@v2
76+
- uses: google-github-actions/auth@v2
6077
with:
6178
credentials_json: '${{ secrets.GCP_SA_KEY }}'
6279

@@ -71,6 +88,6 @@ jobs:
7188
- name: Deploy to Cloud Run using Buildpacks
7289
uses: google-github-actions/deploy-cloudrun@v2
7390
with:
74-
service: angular-blog
91+
service: angular-blog
7592
region: europe-west4
7693
source: .

0 commit comments

Comments
 (0)