-
Notifications
You must be signed in to change notification settings - Fork 47
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
1 changed file
with
86 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,86 @@ | ||
name: Build Images | ||
|
||
on: | ||
push: | ||
branches: | ||
- github-runner | ||
|
||
jobs: | ||
build-images: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
env: | ||
DOCKER_HUB_PARACHAIN: kiltprotocol/kilt-node | ||
DOCKER_HUB_STANDALONE: kiltprotocol/standalone-node | ||
DOCKER_HUB_DIP_PROVIDER_TEMPLATE: kiltprotocol/dip-provider-node-template | ||
DOCKER_HUB_DIP_CONSUMER_TEMPLATE: kiltprotocol/dip-consumer-node-template | ||
AWS_REGISTRY: ${{ secrets.ECR_REGISTRY }} | ||
CI_COMMIT_SHORT_SHA: ${{ github.sha }} | ||
CI_COMMIT_BRANCH: ${{ github.ref_name }} | ||
CI_COMMIT_TAG: ${{ github.ref_name }} | ||
steps: | ||
- name: Free Disk Space | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: true | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Cargo Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-build-images-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-images- | ||
- name: Display AWS and Docker Versions | ||
run: | | ||
aws --version | ||
docker --version | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.ECR_ROLE }} | ||
aws-region: ${{ secrets.ECR_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build Docker Images | ||
run: | | ||
./.maintain/build-image.sh build | ||
- name: Push Image - Commit SHA | ||
if: github.ref_type == 'branch' | ||
run: | | ||
./.maintain/push-image.sh build "${{ env.CI_COMMIT_SHORT_SHA }}" | ||
- name: Push Image - Latest Branch | ||
if: github.ref_type == 'branch' | ||
run: | | ||
./.maintain/push-image.sh build "latest-${{ env.CI_COMMIT_BRANCH }}" | ||
- name: Push Image - Tag | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
./.maintain/push-image.sh build "${{ env.CI_COMMIT_TAG }}" | ||
- name: Push Image - Latest | ||
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-rc') && !contains(github.ref, 'dev-') | ||
run: | | ||
./.maintain/push-image.sh build "latest" |