Skip to content

Commit a1f0f55

Browse files
Merge pull request #20 from laylark/add-docker-hub-ci-action
Add docker hub ci action
2 parents 4d551e9 + ee829d2 commit a1f0f55

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.github/workflows/push.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: push
2+
3+
on: push
4+
5+
jobs:
6+
push:
7+
name: Push to Docker Hub
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Docker meta
11+
id: meta
12+
uses: docker/metadata-action@v3
13+
with:
14+
images: your-username/your-image-name
15+
tags: |
16+
type=ref,prefix=dev-,event=branch
17+
type=semver,pattern={{version}}
18+
type=semver,pattern={{major}}
19+
type=semver,pattern={{major}}.{{minor}}
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v1
22+
- name: Login to DockerHub
23+
uses: docker/login-action@v1
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
- name: Build and push
28+
id: docker_build
29+
uses: docker/build-push-action@v2
30+
with:
31+
push: true
32+
tags: ${{ steps.meta.outputs.tags }}
33+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Be the change et al if Windows is your main and you wanna [raise a PR](CONTRIBUT
2020
* [Setup](#setup)
2121
* [Usage](#usage)
2222
* [Mac and Linux users](#mac-and-linux-users)
23+
* [Pushing to Docker Hub with CI](#pushing-to-docker-hub-with-ci)
2324
* [TODO](#todo)
2425

2526
## Setup
@@ -37,6 +38,19 @@ Be the change et al if Windows is your main and you wanna [raise a PR](CONTRIBUT
3738
### Mac and Linux users
3839
Development environments and tooling are first-class citizens on macOS and *nix. For Windows faithfuls, please setup [WSL](markdown/wsl.md).
3940

41+
## Pushing to Docker Hub with CI
42+
Docker Hub is a cloud-based repository in which Docker users and partners create, test, store and distribute container images. Docker images are pushed to Docker Hub through the docker push command. A single Docker Hub repository can hold many Docker images (stored as tags).
43+
44+
Automated CI is implemented via GitHub Actions to build and push this repository's image to Docker Hub in `/.github/workflows/push.yml`.
45+
46+
### What you need to modify in this file
47+
48+
* Look for `images: your-username/your-image-name` and change to your respective Docker Hub username and image name.
49+
* Add repository secrets for `DOCKERHUB_TOKEN` and `DOCKERHUB_USERNAME` on this repository on GitHub.
50+
* Here are the [instructions to create a token](https://docs.docker.com/docker-hub/access-tokens/#create-an-access-token).
51+
52+
Here are the [instructions to disable this action](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) if you don't want this feature.
53+
4054
## TODO
4155
* [Open Issues](https://github.com/pythoninthegrass/python_template/issues)
4256
* Markdown automation

0 commit comments

Comments
 (0)