Skip to content

Commit

Permalink
Migrate to gha and add vars to push to ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-grr committed Oct 29, 2024
1 parent 3976744 commit 22e9e8b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build
on:
push:
branches:
- master

jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to ECR
uses: docker/login-action@v3
with:
registry: ${{ vars.AWS_ECR_MASTER_ACCOUNT }}.dkr.ecr.${{ vars.AWS_ECR_MASTER_REGION }}.amazonaws.com
username: ${{ secrets.AWS_ECR_MASTER_ACCESS_KEY }}
password: ${{ secrets.AWS_ECR_MASTER_SECRET_ACCESS_KEY }}

- name: build
run: |
make -f Makefile build push BRANCH=${{ github.ref_name }} NPM_TOKEN=${{ secrets.NPM_TOKEN }} ECR_ACCOUNT=${{ vars.AWS_ECR_MASTER_ACCOUNT }} ECR_REGION=${{ vars.AWS_ECR_MASTER_REGION }}
make -f Makefile git-prep git-push GH_TOKEN=${{ secrets.GH_ADMIN_TOKEN }} BRANCH=${{ github.ref_name }}
File renamed without changes.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ IMAGE_REPO = teamwork/$(NAME)
CACHE_TAG = $(IMAGE_REPO):cache-$(BRANCH)
TAG = $(IMAGE_REPO):$(VERSION)

ECR_IMAGE_REPO = $(ECR_ACCOUNT).dkr.ecr.$(ECR_REGION).amazonaws.com/teamwork/$(NAME)
ECR_CACHE_TAG = $(ECR_IMAGE_REPO):cache-$(BRANCH)
ECR_TAG = $(ECR_IMAGE_REPO):$(VERSION)

.PHONY: default install build push chart-update git-prep git-push install-docker install-buildx install-yq

#
Expand All @@ -26,6 +30,7 @@ build:
--build-arg BUILD_VCS_REF=$(shell git rev-parse --short HEAD) \
--build-arg BUILD_VERSION=$(VERSION) \
-t $(TAG) \
-t $(ECR_TAG) \
--load \
.

Expand All @@ -37,6 +42,7 @@ push:
--cache-from=type=registry,ref=$(CACHE_TAG) \
--cache-to=type=registry,ref=$(CACHE_TAG),mode=max \
-t $(TAG) \
-t $(ECR_TAG) \
--push \
--progress=plain \
.
Expand All @@ -45,8 +51,8 @@ push:
# Helm chart updates
#
chart-update:
yq w -i docker/helm/Chart.yaml appVersion $(VERSION)
yq w -i docker/helm-eks/Chart.yaml appVersion $(VERSION)
yq eval -i '.appVersion = "$(VERSION)"' docker/helm/Chart.yaml
yq eval -i '.appVersion = "$(VERSION)"' docker/helm-eks/Chart.yaml

#
# GitOps deployment will be triggered by a committed change to helm chart
Expand Down

0 comments on commit 22e9e8b

Please sign in to comment.