Skip to content

Commit

Permalink
GitHub Action for Automatic Docker Registry Push (#136)
Browse files Browse the repository at this point in the history
# Background
Locally pushing image every time you make a release is tedious.

## Checklist Before PR Review
- [x] The following has been handled:
  -  `Draft` is set for this PR
  - `Title` is checked
  - `Background` is filled
  - `TODOs` are filled
  - `Assignee` is set
  - `Labels` are set
  - `development` is linked if related issue exists

## Checklist (Right Before PR Review Request)
- [x] The following has been handled:
  - `yarn inspect` is run
  - `TODOs` are handled and checked
  - Final Operation Check is done
  - Make this PR as an open PR

## Checklist (Reviewers)
- [x] Check if there are any other missing TODOs that are not yet listed
- [x] Review Code
- [x] Every item on the checklist has been addressed accordingly
- [x] If `development` is associated to this PR, you must check if every
TODOs are handled
  • Loading branch information
mlajkim authored Jul 2, 2024
1 parent f668cbd commit 57e2009
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ajktown
password: ${{ secrets.AJKTOWN_ORG_ACTION }}

- name: Build the Docker image for PR
if: github.event_name == 'pull_request'
run: docker build . --file Dockerfile --tag ajktown/api:pr${{ github.event.pull_request.number }}

- name: Push the Docker image for PR
if: github.event_name == 'pull_request'
run: docker push ajktown/api:pr${{ github.event.pull_request.number }}

- name: Build the Docker image as latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: docker build . --file Dockerfile --tag ajktown/api:latest

- name: Push the Docker image as latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: docker push ajktown/api:latest
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [Overview](#overview)
- [For Developers](#for-developers)
- [Public Image](#public-image)
- [Push image command](#push-image-command)
- [Push image command locally](#push-image-command-locally)
- [For Envoy](#for-envoy)
- [About the starter of this project](#about-the-starter-of-this-project)
- [Description](#description)
Expand All @@ -37,13 +37,12 @@ https://api.ajktown.com

https://hub.docker.com/r/ajktown/api/tags

### Push image command
You musth have permission to push to the repository.
### Push image command locally
By default, the GitHub Action will build and push the image to the Docker Hub. If you want to push the image locally, you can use the following commands:
```sh

docker build -t ajktown/api:latest .
docker push ajktown/api:latest
kubectl apply -f k8s

```

Expand Down

0 comments on commit 57e2009

Please sign in to comment.