-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
92 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Fleetbase Registry CI/CD | ||
|
||
on: | ||
push: | ||
branches: ["deploy/*"] | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
PROJECT: fleetbase-registry | ||
|
||
jobs: | ||
build_service: | ||
name: Build and Deploy the Registry | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: read # This is required for actions/checkout | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Set Dynamic ENV Vars | ||
run: | | ||
SHORT_COMMIT=$(echo $GITHUB_SHA | cut -c -8) | ||
echo "VERSION=${SHORT_COMMIT}" >> $GITHUB_ENV | ||
echo "STACK=$(basename $GITHUB_REF)" >> $GITHUB_ENV | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_NUMBER }}:role/${{ env.PROJECT }}-${{ env.STACK }}-deployer | ||
role-session-name: github | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build and Release | ||
uses: docker/bake-action@v2 | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}-${{ env.STACK }} | ||
VERSION: ${{ env.VERSION }} | ||
CACHE: type=gha | ||
with: | ||
push: true | ||
files: | | ||
./docker-bake.hcl | ||
- name: Download ecs-tool | ||
run: | | ||
wget -O ecs-tool.tar.gz https://github.com/springload/ecs-tool/releases/download/1.9.6/ecs-tool_1.9.6_linux_amd64.tar.gz && tar -xvf ecs-tool.tar.gz ecs-tool | ||
- name: Deploy the images 🚀 | ||
run: |- | ||
set -eu | ||
# run deploy.sh script before deployments | ||
./ecs-tool deploy --image_tag '${{ env.VERSION }}' --cluster ${{ env.PROJECT }}-${{ env.STACK }} -s app |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// docker-bake.hcl | ||
variable "REGISTRY" { default = "" } | ||
variable "VERSION" { default = "latest" } | ||
variable "CACHE" { default = "" } | ||
|
||
group "default" { | ||
targets = ["app"] | ||
} | ||
|
||
target "app" { | ||
context = "./" | ||
dockerfile = "Dockerfile.verdaccio" | ||
platforms = [ | ||
"linux/amd64", | ||
] | ||
target = "aws-app" | ||
|
||
tags = notequal("", REGISTRY) ? formatlist( | ||
"${REGISTRY}:%s", | ||
compact(["latest", VERSION]) | ||
) : [] | ||
|
||
cache-from = notequal("", CACHE) ? ["${CACHE}"] : [] | ||
cache-to = notequal("", CACHE) ? ["${CACHE},mode=max,ignore-error=true"] : [] | ||
} |