Skip to content

Commit a96cadd

Browse files
committed
updaitng change on docker build fro ecr to ghcr
1 parent 9853593 commit a96cadd

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed
Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
name: DEV - N.V - Coordinate core Build and Push
1+
name: DEV - Build and Push to GHCR
22

33
on:
4+
push:
5+
branches:
6+
- dev
7+
- AN-205-ghcr-build-update
48
pull_request:
59
types:
610
- closed
@@ -10,37 +14,35 @@ on:
1014
permissions:
1115
contents: write
1216
pull-requests: write
17+
packages: write
1318

1419
env:
15-
AWS_REGION: us-east-1
16-
DOCKER_REGISTRY: 992382389965.dkr.ecr.us-east-1.amazonaws.com
20+
IMAGE_NAME: ${{ github.repository_owner }}/coordinatecore
1721
ENV_TYPE: dev
18-
SERVICE_NAME: "mara-sidechain-beta-coordinate-core"
1922

2023
jobs:
2124
build-and-push:
2225
name: Build and Push Docker Image
23-
if: ${{ github.event.pull_request.merged == true }}
26+
if: ${{ github.event_name == 'push' || github.event.pull_request.merged == true }}
2427
runs-on: governance-testenv-github-self-hosted
2528

2629
steps:
2730
- name: Checkout Code
2831
uses: actions/checkout@v4
29-
with:
30-
ref: dev
3132

3233
- name: Create new tag (semantic versioning)
3334
id: tag
3435
uses: mathieudutour/[email protected]
3536
with:
3637
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
release_branches: dev
38+
release_branches: dev,main
3839
default_bump: patch # can be major/minor/patch
3940

4041
- name: Install Dependencies
4142
run: |
42-
sudo apt-get install -y \
43+
sudo apt-get update && sudo apt-get install -y \
4344
build-essential \
45+
cmake \
4446
libtool \
4547
autotools-dev \
4648
automake \
@@ -56,34 +58,36 @@ jobs:
5658
systemtap-sdt-dev \
5759
curl
5860
59-
- name: autogen
60-
run: pwd && ./autogen.sh
61-
62-
- name: configure
63-
run: ./configure --without-ui
61+
- name: Configure with CMake
62+
run: cmake -B build -DWITH_ZMQ=ON
6463

65-
- name: make
66-
run: make
64+
- name: Build with CMake
65+
run: cmake --build build
6766

68-
- name: Set Up AWS Credentials
69-
uses: aws-actions/configure-aws-credentials@v4
67+
- name: Verify build artifacts
68+
run: ls -la build/bin/
69+
70+
- name: Log in to GitHub Container Registry
71+
uses: docker/login-action@v3
7072
with:
71-
aws-access-key-id: ${{ secrets.MT_AWS_ACCESS_KEY_ID }}
72-
aws-secret-access-key: ${{ secrets.MT_AWS_SECRET_ACCESS_KEY }}
73-
aws-session-token: ${{ secrets.MT_AWS_SESSION_TOKEN }} # Only if using temporary credentials
74-
aws-region: ${{ env.AWS_REGION }}
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
7576

77+
- name: Extract metadata (tags, labels) for Docker
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: ghcr.io/${{ env.IMAGE_NAME }}
82+
tags: |
83+
type=raw,value=${{ steps.tag.outputs.new_tag }}
84+
type=raw,value=latest
85+
type=ref,event=branch
7686
77-
- name: Log In to Amazon ECR
78-
run: |
79-
aws ecr get-login-password --region ${{ env.AWS_REGION }} | \
80-
sudo docker login --username AWS --password-stdin ${{ env.DOCKER_REGISTRY }}
81-
- name: Build Docker Image
82-
run: |
83-
sudo docker build -t ${{ env.DOCKER_REGISTRY }}/${{ env.SERVICE_NAME }}:${{ steps.tag.outputs.new_tag }} \
84-
-t ${{ env.DOCKER_REGISTRY }}/${{ env.SERVICE_NAME }}:latest .
85-
# sudo docker tag ${{ env.SERVICE_NAME }}:latest ${{ env.DOCKER_REGISTRY }}/${{ env.SERVICE_NAME }}:${{ steps.tag.outputs.new_tag }}
86-
- name: Push Docker Image to ECR
87-
run: |
88-
sudo docker push ${{ env.DOCKER_REGISTRY }}/${{ env.SERVICE_NAME }}:${{ steps.tag.outputs.new_tag }}
89-
sudo docker push ${{ env.DOCKER_REGISTRY }}/${{ env.SERVICE_NAME }}:latest
87+
- name: Build and Push Docker Image
88+
uses: docker/build-push-action@v5
89+
with:
90+
context: .
91+
push: true
92+
tags: ${{ steps.meta.outputs.tags }}
93+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)