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

GitHub Action for Automatic Docker Registry Push #136

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading