Skip to content

Commit dffab24

Browse files
Update build image in CICD
1 parent 9e11034 commit dffab24

File tree

3 files changed

+48
-30
lines changed

3 files changed

+48
-30
lines changed

.github/workflows/development_pipeline.yml

+10-30
Original file line numberDiff line numberDiff line change
@@ -47,41 +47,21 @@ jobs:
4747
DATABASE_TEST_URL: postgresql://db_user:db_password@localhost/db_test
4848
run: python -m flask tests
4949

50-
deploy-service:
51-
needs: build-test
52-
runs-on: ubuntu-latest
53-
env:
54-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
55-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
56-
AWS_REGION: "us-east-1"
57-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
58-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
59-
steps:
60-
- name: Checkout Repository
61-
uses: actions/checkout@v2
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v2
6252

6353
- name: Login to Docker Hub
6454
id: docker_hub_auth
65-
uses: docker/login-action@v1
55+
uses: docker/login-action@v2
6656
with:
6757
username: ${{ secrets.DOCKERHUB_USERNAME }}
6858
password: ${{ secrets.DOCKERHUB_PASSWORD }}
6959

70-
- name: Build Docker Image
71-
id: build_docker
72-
run: |
73-
docker compose build api_service
74-
75-
# Add tag
76-
docker tag api_image:latest ${{ secrets.DOCKERHUB_USERNAME }}/api_image:latest
77-
78-
- name: Push Docker Image
79-
id: push_images
80-
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/api_image:latest
81-
82-
- name: Deploy to AWS CloudFormation
83-
uses: aws-actions/aws-cloudformation-github-deploy@v1
60+
- name: Build and push
61+
uses: docker/build-push-action@v4
8462
with:
85-
name: MyStackEC2
86-
template: myStack.yaml
87-
parameter-overrides: "MyParam1=myValue,MyParam2=${{ secrets.MY_SECRET_VALUE }}"
63+
context: .
64+
push: true
65+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/flask_template_image:latest
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max

.github/workflows/production_pipeline.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ jobs:
4747
DATABASE_TEST_URL: postgresql://db_user:db_password@localhost/db_test
4848
run: python -m flask tests
4949

50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v2
52+
53+
- name: Login to Docker Hub
54+
id: docker_hub_auth
55+
uses: docker/login-action@v2
56+
with:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
59+
60+
- name: Build and push
61+
uses: docker/build-push-action@v4
62+
with:
63+
context: .
64+
push: true
65+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/flask_template_image:latest
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max
68+
5069
create-config-infrastructure:
5170
runs-on: ubuntu-latest
5271
needs:

.github/workflows/staging_pipeline.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ jobs:
4747
DATABASE_TEST_URL: postgresql://db_user:db_password@localhost/db_test
4848
run: python -m flask tests
4949

50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v2
52+
53+
- name: Login to Docker Hub
54+
id: docker_hub_auth
55+
uses: docker/login-action@v2
56+
with:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
59+
60+
- name: Build and push
61+
uses: docker/build-push-action@v4
62+
with:
63+
context: .
64+
push: true
65+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/flask_template_image:latest
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max
68+
5069
create-config-infrastructure:
5170
runs-on: ubuntu-latest
5271
needs:

0 commit comments

Comments
 (0)