Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 39 setup build and publish image #48

Merged
merged 49 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7af15fb
feat: Setup docker build and publish on ghcr
kouamschekina Mar 5, 2024
a8b3189
feat: Setup docker build and publish on ghcr
kouamschekina Mar 5, 2024
6ef381d
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
c0d78e6
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
d8fed14
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
7ff8077
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
c89a25e
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
9c4769d
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
405196f
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
1b0ab88
feat: Created workflow file to build and publish docker image on docker
kouamschekina Mar 5, 2024
04b1cb1
fix: Updated workflow files to handle the Change String Case
kouamschekina Mar 5, 2024
2c91199
feat: Created a workflow file that builds and pushes docker images fo…
kouamschekina Mar 5, 2024
d15c9e4
Merge branch 'main' into feature-39-setup-build-and-publish-image
stephane-segning Mar 5, 2024
496b12a
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
8777052
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 5, 2024
37ef23e
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
eb42070
fix: Updated the Change String Case in th workflow files
kouamschekina Mar 5, 2024
52df277
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
25ebe82
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
4663b73
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
f8169de
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
2a2f93c
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
bf0fabf
fix: changed string conversion using change string case
kouamschekina Mar 6, 2024
29097fa
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
5a9a741
fix: handled the permissions
kouamschekina Mar 6, 2024
c46762d
fix: handled the permissions on the frontend and translator
kouamschekina Mar 6, 2024
e90463d
fix: handled the permissions on the translator
kouamschekina Mar 6, 2024
00c9d8b
fix: handled the permissions on the translator
kouamschekina Mar 6, 2024
0f0950a
fix: handled image url for frontend
kouamschekina Mar 6, 2024
a9811aa
fix: handled image url for frontend
kouamschekina Mar 6, 2024
0099946
fix: update env with image names
kouamschekina Mar 6, 2024
b2f4043
fix: handled image url for frontend
kouamschekina Mar 6, 2024
4a2c27a
fix: modified version of the setup-buildx-action
kouamschekina Mar 6, 2024
ee68b12
Merge branch 'ADORSYS-GIS:main' into feature-39-setup-build-and-publi…
kouamschekina Mar 6, 2024
c24ba9f
feat: Documented the process used to build and upload docker images t…
kouamschekina Mar 6, 2024
567e1ea
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 6, 2024
4367cff
fix: Updated tags in the frontend
kouamschekina Mar 6, 2024
538e4a5
feat: update rust.yml
stephane-segning Mar 7, 2024
6c3fca7
feat: update rust.yml to fix CI/CD
stephane-segning Mar 7, 2024
3d9f561
fix: Updated the building and uploading docker images' docs
kouamschekina Mar 7, 2024
014f999
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 7, 2024
e36e5d0
fix: Updated tags in the frontend and backend files
kouamschekina Mar 7, 2024
9616c37
Merge branch 'main' into feature-39-setup-build-and-publish-image
kouamschekina Mar 7, 2024
e6ccbfb
fix: ci/cd update and rename rust.yml to build-translator.yml
stephane-segning Mar 7, 2024
8981c33
fix: ci/cd - update and rename maven.yml to build-service.yml
stephane-segning Mar 7, 2024
b254b8c
fix: typo error in job's name
stephane-segning Mar 7, 2024
f57cbc1
fix: renamed the node.yml to build-frontend.yaml and modified the bui…
kouamschekina Mar 7, 2024
1deff03
Merge branch 'feature-39-setup-build-and-publish-image' of github.com…
kouamschekina Mar 7, 2024
396c392
fix: delete .github/workflows/node.yml
stephane-segning Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

Expand All @@ -21,5 +25,36 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Backend
run: cd power-pay-backend && mvn package
run: cd power-pay-backend && mvn package

- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{github.repository}}

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- name: Enable create organization packages
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
https://api.github.com/orgs/${{ github.repository_owner }}/actions/permissions/orgs \
-d '{"permission": "write"}'

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ./power-pay-backend
file: ./power-pay-backend/Dockerfile
push: true
tags: ghcr.io/${{ steps.string.outputs.lowercase }}:latest


32 changes: 31 additions & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,35 @@ jobs:
node-version: 18
- name: Npm install
run: cd power-pay-frontend && npm ci

- name: Login to the Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Frontend
run: cd power-pay-frontend && npm run build
run: cd power-pay-frontend && npm run build

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- id: string
uses: AsZc/change-string-case-action@v6
with:
string: ${{github.repository}}

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- name: Enable create organization packages
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
https://api.github.com/orgs/${{ github.repository_owner }}/actions/permissions/orgs \
-d '{"permission": "write"}'

- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./power-pay-frontend
file: ./power-pay-frontend/Dockerfile
push: true
tags: ghcr.io/${{ steps.string.outputs.lowercase }}:latest

30 changes: 29 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,32 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build Translator
run: cd power-pay-translator && cargo build --verbose && cargo test --verbose
run: cd power-pay-translator && cargo build --verbose && cargo test --verbose

- name: Login to the Docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- id: String
uses: AsZc/change-string-case-action@v6
with:
string: ${{ github.repository }}

stephane-segning marked this conversation as resolved.
Show resolved Hide resolved
- name: Enable create organization packages
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
https://api.github.com/orgs/${{ github.repository_owner }}/actions/permissions/orgs \
-d '{"permission": "write"}'

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./power-pay-translator
file: ./power-pay-translator/Dockerfile
push: true
tags: ghcr.io/${{ steps.string.outputs.lowercase }}:latest
16 changes: 16 additions & 0 deletions docs/Setup-build-and-push-docker-images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Building and Uploading Docker Images to ghcr.io using Github Action
This document outlines the steps to build a Docker image and upload it to ghcr.io using a Github Action. The process involves building the frontend, backend and using a translator service to communicate with them.

## Prerequisites
- A Github repository for each sub-project with a Dockerfile.
- A personal access token (PAT) with write:packages scope. You can create a PAT by following these steps: [Github Docs ](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

### Steps
1- Create new files named .github/workflows/maven.yml, .github/workflows/node.yml, and .github/workflows/rust.yml in the main project directory for the backend, frontend and translator respectively.
2 - In the above created files, define the Github Action workflow for each.
3- Save the various .yml files.
4- Commit and push the changes to your repository.
5- Github Action will automatically trigger the workflow defined in the above files whenever pushed to the mentioned branch.
6- The workflow will build the frontend, backend and translator Docker images using their respective Dockerfiles and push them to ghcr.io using the provided credentials.
7- You can access the Docker images on ghcr.io at ghcr.io/<owner>/<repository>/<image>:<tag>, where <owner> is your GitHub username or organization, <repository> is the name of your repository, <image> is the name of the Docker image(frontend, backend or translator) and <tag> is the SHA of the commit.
8- Make sure to update your deployment or other relevant scripts to use the newly built Docker images from ghcr.io.
Loading