Skip to content

Commit

Permalink
Merge pull request #84 from uptick/dev-878/modify-ci-workflow-to-push…
Browse files Browse the repository at this point in the history
…-docker-images-to-two-repos

Use main ci for building docker images
  • Loading branch information
mdesouky authored Oct 24, 2024
2 parents 4d4a2cf + 98dfa58 commit 65f36fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
45 changes: 15 additions & 30 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,21 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2

- name: Docker Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Check out the repo
uses: actions/checkout@v3

- name: Pull latest image. Build docker image and publish it.
env:
latest_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:latest
current_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:${{github.event.release.tag_name}}
run: |
echo ${{secrets.CLUSTER_KEY}} | base64 -d > cluster.key
docker pull $latest_image
docker build -t $latest_image --cache-from $latest_image .
docker push $latest_image
docker tag $latest_image $current_image
docker push $current_image
echo "Published image at: $current_image"
build:
name: Build and Push Docker Image
uses: uptick/actions/.github/workflows/ci.yaml@main
secrets:
SECRET_ENV: "${{ secrets.CLUSTER_KEY }}"
#https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml
with:
aws-iam-role-arn: "arn:aws:iam::305686791668:role/default-github-actions-ci-role"
docker-enabled: true
docker-context: "."
docker-tag: ${{github.event.release.tag_name}}
docker-tag-latest: true
docker-image-platforms: linux/amd64
docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops"
command: echo $SECRET_ENV | base64 -d > cluster.key

publish_helm_chart:
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ jobs:
command: |
mise run install
mise run ci
build:
name: Build and Push Docker Image
uses: uptick/actions/.github/workflows/ci.yaml@main
secrets:
SECRET_ENV: "${{ secrets.CLUSTER_KEY }}"
#https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml
with:
aws-iam-role-arn: "arn:aws:iam::305686791668:role/default-github-actions-ci-role"
docker-enabled: true
docker-context: "."
docker-prefix: test
docker-tag-latest: false
docker-image-platforms: linux/amd64
docker-push: false
docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops"
command: echo $SECRET_ENV | base64 -d > cluster.key

0 comments on commit 65f36fe

Please sign in to comment.