Skip to content

Commit d45d98a

Browse files
authored
Merge pull request #21 from Virtual-Finland-Development/feat/cicd-access-from-infra
build: use infra as cicd auth
2 parents 2b0274d + 6b0f1c6 commit d45d98a

3 files changed

Lines changed: 73 additions & 76 deletions

File tree

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
11
name: Build, Test, Deploy
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
environment:
7-
description: Environment where to deploy the stack (dev, staging)
8-
type: environment
9-
required: true
10-
workflow_call:
11-
inputs:
12-
environment:
13-
description: Environment where to deploy the stack (dev, staging)
14-
type: string
15-
required: true
16-
17-
env:
18-
AWS_REGION: eu-north-1
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: Environment where to deploy the stack (dev, staging)
8+
type: environment
9+
required: true
10+
workflow_call:
11+
inputs:
12+
environment:
13+
description: Environment where to deploy the stack (dev, staging)
14+
type: string
15+
required: true
1916

2017
jobs:
21-
build-test-deploy:
22-
name: Build, test and deploy ${{ inputs.environment }}
23-
runs-on: ubuntu-latest
24-
environment: ${{ inputs.environment }}
25-
outputs:
26-
url: ${{ steps.pulumi.outputs.url }}
27-
steps:
28-
- uses: actions/checkout@v3
29-
- name: Use Node.js
30-
uses: actions/setup-node@v3
31-
with:
32-
node-version: 18.x
33-
- name: Build
34-
run: |
35-
npm install
36-
npm run build
37-
- name: Test
38-
run: |
39-
npm run test
40-
- name: prepare deployment
41-
run: |
42-
npm run build:infra
43-
- name: Configure AWS credentials
44-
uses: aws-actions/configure-aws-credentials@v1
45-
with:
46-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
47-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
48-
aws-region: ${{ env.AWS_REGION }}
49-
- name: Deploy with Pulumi
50-
id: pulumi
51-
uses: pulumi/actions@v3
52-
with:
53-
work-dir: ./infra
54-
command: up
55-
stack-name: virtualfinland/${{ inputs.environment }}
56-
upsert: true
57-
env:
58-
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
59-
- name: Tag the deployment
60-
uses: Virtual-Finland-Development/automatic-release-action@v1.0
61-
if: ${{ inputs.environment == 'staging' }}
62-
with:
63-
environment: ${{ inputs.environment }}
64-
githubToken: ${{ secrets.GITHUB_TOKEN }}
18+
build-test-deploy:
19+
name: Build, test and deploy ${{ inputs.environment }}
20+
runs-on: ubuntu-latest
21+
permissions:
22+
id-token: write
23+
contents: read
24+
environment: ${{ inputs.environment }}
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Use Node.js
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 18.x
31+
- name: Build
32+
run: |
33+
npm install
34+
npm run build
35+
- name: Test
36+
run: |
37+
npm run test
38+
- name: prepare deployment
39+
run: |
40+
npm run build:infra
41+
- name: Configure AWS credentials
42+
uses: Virtual-Finland-Development/infrastructure/.github/actions/configure-aws-credentials@main
43+
with:
44+
environment: ${{ inputs.environment }}
45+
aws-region: ${{ secrets.AWS_REGION }}
46+
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
47+
- name: Deploy with Pulumi
48+
id: pulumi
49+
uses: pulumi/actions@v4
50+
with:
51+
work-dir: ./infra
52+
command: up
53+
stack-name: virtualfinland/${{ inputs.environment }}
54+
upsert: true
55+
env:
56+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
57+
- name: Tag the deployment
58+
uses: Virtual-Finland-Development/automatic-release-action@v1.0
59+
if: ${{ inputs.environment == 'staging' }}
60+
with:
61+
environment: ${{ inputs.environment }}
62+
githubToken: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/deploy-dev.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: "Dev: build, test and deploy"
1+
name: 'Dev: build, test and deploy'
22
on:
3-
push:
4-
branches: ["main"]
5-
workflow_dispatch:
3+
push:
4+
branches: ['main']
5+
workflow_dispatch:
66

77
jobs:
8-
deploy-dev:
9-
uses: Virtual-Finland-Development/codesets/.github/workflows/build-test-deploy.yml@main
10-
secrets: inherit
11-
with:
12-
environment: dev
8+
deploy-dev:
9+
uses: Virtual-Finland-Development/codesets/.github/workflows/build-test-deploy.yml@main
10+
secrets: inherit
11+
with:
12+
environment: dev
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
name: "Staging: build, test and deploy"
1+
name: 'Staging: build, test and deploy'
22
on:
3-
workflow_dispatch:
4-
branches: ["main"]
3+
workflow_dispatch:
54

65
jobs:
7-
deploy-staging:
8-
uses: Virtual-Finland-Development/codesets/.github/workflows/build-test-deploy.yml@main
9-
secrets: inherit
10-
with:
11-
environment: staging
6+
deploy-staging:
7+
uses: Virtual-Finland-Development/codesets/.github/workflows/build-test-deploy.yml@main
8+
secrets: inherit
9+
with:
10+
environment: staging

0 commit comments

Comments
 (0)