-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 2.73 KB
/
ci-latest.yaml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: CI 1.0.x-latest
on:
push:
branches:
# - '1.0.x'
- 'ci-refactor'
# paths:
# - 'src/**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build_publish:
name: Build and Publish image
environment: dev
permissions:
id-token: write
contents: read
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 11
- name: Install node 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Installing openapi-generator-cli
run: npm install -g @openapitools/openapi-generator-cli
- name: Build and test project
run: sbt ++${{ matrix.scala }} test
# - name: Get 1.0.x-SNAPSHOTS versionIds
# id: version
# uses: castlabs/[email protected]
# with:
# version: 1.0.x-SNAPSHOT
#
# - name: Delete 1.0.x-SNAPSHOTS versions
# if: ${{ steps.version.outputs.ids != '' }}
# uses: actions/delete-package-versions@v2
# with:
# package-version-ids: ${{ steps.version.outputs.ids }}
- name: Publish project
run: sbt ++${{ matrix.scala }} publish
- name: Generate Docker target
run: sbt ++${{ matrix.scala }} docker:stage
- name: Normalize repo name
run: |
# github.reposiory is in the format "owner/repository-name", we need only the repo name
NORM_REPO="$(echo "${{ github.repository }}" | cut -d"/" -f2)"
echo "NORM_REPO=$NORM_REPO" >> "$GITHUB_ENV"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.IAM_ROLE_ARN }}
role-session-name: ${{ env.NORM_REPO }}-${{ github.run_number }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Docker build and push on ECR
uses: docker/build-push-action@v2
with:
context: ./target/docker/stage
file: ./target/docker/stage/Dockerfile
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.NORM_REPO }}:${{ github.ref_name }}-latest
${{ steps.login-ecr.outputs.registry }}/${{ env.NORM_REPO }}:commit-${{ github.sha }}