-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (57 loc) · 2.07 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Build
on:
release:
types: [published, edited]
push:
branches:
- main
permissions:
id-token: write # Required for OIDC
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
env:
ecr_image_name: 374269020027.dkr.ecr.eu-west-2.amazonaws.com/delius-core-user-management
ghcr_image_name: ghcr.io/${{ github.repository_owner }}/delius-core-user-management
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Set version
run: |
version=${tag:-dev}
echo "version=$version" | tee -a "$GITHUB_ENV"
echo "ORG_GRADLE_PROJECT_version=$version" | tee -a "$GITHUB_ENV"
env:
tag: ${{ github.event.release.tag_name }}
- name: Build image
run: ./gradlew clean build bootBuildImage --info --build-cache
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Push to GHCR
run: |
docker tag "delius-user-management:$version" "$ghcr_image_name:$version"
docker tag "delius-user-management:$version" "$ghcr_image_name:latest"
docker push "$ghcr_image_name:$version"
docker push "$ghcr_image_name:latest"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::326912278139:role/modernisation-platform-oidc-cicd
role-session-name: delius-user-management-build-${{ github.run_number }}
aws-region: eu-west-2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
with:
registries: "374269020027"
- name: Push to Amazon ECR
run: |
docker tag "delius-user-management:$version" "$ecr_image_name:$version"
docker tag "delius-user-management:$version" "$ecr_image_name:latest"
docker push "$ecr_image_name:$version"
docker push "$ecr_image_name:latest"