-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf3202f
commit 756a467
Showing
1 changed file
with
27 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ name: CI 1.0.x-latest | |
on: | ||
push: | ||
branches: | ||
- '1.0.x' | ||
paths: | ||
- 'src/**' | ||
# - '1.0.x' | ||
- 'ci-refactor' | ||
# paths: | ||
# - 'src/**' | ||
|
||
jobs: | ||
build_publish: | ||
|
@@ -20,6 +21,7 @@ jobs: | |
scala: [2.13.10] | ||
java: [temurin@11] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout current branch (full) | ||
uses: actions/checkout@v2 | ||
|
@@ -33,18 +35,6 @@ jobs: | |
distribution: temurin | ||
java-version: 11 | ||
|
||
- name: Cache sbt | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.sbt | ||
~/.ivy2/cache | ||
~/.coursier/cache/v1 | ||
~/.cache/coursier/v1 | ||
~/AppData/Local/Coursier/Cache/v1 | ||
~/Library/Caches/Coursier/v1 | ||
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
- name: Install node 16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
|
@@ -53,48 +43,52 @@ jobs: | |
- 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 | ||
if: github.ref == 'refs/heads/1.0.x' | ||
uses: castlabs/[email protected] | ||
with: | ||
version: 1.0.x-SNAPSHOT | ||
|
||
- name: Deleting 1.0.x-SNAPSHOTS versions | ||
if: ${{ github.ref == 'refs/heads/1.0.x' && steps.version.outputs.ids != '' }} | ||
- 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: Regenerating code | ||
run: sbt ++${{ matrix.scala }} generateCode | ||
|
||
- name: Build and Test | ||
run: sbt ++${{ matrix.scala }} test | ||
|
||
- 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" | ||
# but we cannot use "/" character in the role session 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: ${{ vars.IAM_ROLE_ARN }} | ||
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: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
COMMIT_SHA: ${{ github.sha }} | ||
run: 'sbt ++${{ matrix.scala }} docker:publish' | ||
- 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 }} |