Skip to content

Commit a8e7fb9

Browse files
Update CI
1 parent 5dbd4c2 commit a8e7fb9

File tree

3 files changed

+69
-40
lines changed

3 files changed

+69
-40
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Very little of this gets tested on Windows hosts. Windows Subsystem for Linux (W
1414
Be the change et al if Windows is your main and you wanna [raise a PR](CONTRIBUTING.md) with broad instructions on getting tooling working under Windows (e.g., docker, poetry, playwright.)
1515

1616
**Table of Contents**
17-
* [python_template](#python_template)
17+
* [python\_template](#python_template)
1818
* [Summary](#summary)
1919
* [Caveat Emptor](#caveat-emptor)
2020
* [Setup](#setup)
@@ -40,17 +40,20 @@ Be the change et al if Windows is your main and you wanna [raise a PR](CONTRIBUT
4040
Development environments and tooling are first-class citizens on macOS and *nix. For Windows faithfuls, please setup [WSL](markdown/wsl.md).
4141

4242
## Pushing to Docker Hub with CI
43-
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+
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).
4444

45-
Automated CI is implemented via GitHub Actions to build and push this repository's image to Docker Hub in `/.github/workflows/push.yml`.
45+
Automated CI is implemented via GitHub Actions to build and push this repository's image to Docker Hub in `.github/workflows/ci.yml`.
4646

4747
### What you need to modify in this file
48+
* Add repository secrets (Docker Hub)
49+
* `DOCKERHUB_TOKEN`
50+
* `DOCKERHUB_USER`
51+
* Add environment variable (image name)
52+
* `APP_NAME`
4853

49-
* Look for `images: your-username/your-image-name` and change to your respective Docker Hub username and image name.
50-
* Add repository secrets for `DOCKERHUB_TOKEN` and `DOCKERHUB_USERNAME` on this repository on GitHub.
51-
* Here are the [instructions to create a token](https://docs.docker.com/docker-hub/access-tokens/#create-an-access-token).
54+
[Instructions to create a token](https://docs.docker.com/docker-hub/access-tokens/#create-an-access-token).
5255

53-
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.
56+
[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.
5457

5558
## TODO
5659
* [Open Issues](https://github.com/pythoninthegrass/python_template/issues)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ci
2+
3+
on:
4+
schedule:
5+
- cron: "0 10 * * *"
6+
push:
7+
branches:
8+
- "**"
9+
tags:
10+
- "v*.*.*"
11+
pull_request:
12+
branches:
13+
- "main"
14+
15+
env:
16+
docker_user: ${{ secrets.DOCKERHUB_USERNAME }}
17+
app_name: ${{ vars.APP_NAME }}
18+
19+
jobs:
20+
docker:
21+
strategy:
22+
fail-fast: true
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Docker meta
28+
id: meta
29+
uses: docker/metadata-action@v4
30+
with:
31+
# list of Docker images to use as base name for tags
32+
images: |
33+
${{ env.docker_user }}/${{ env.app_name }}
34+
# generate Docker tags based on the following events/attributes
35+
tags: |
36+
type=schedule
37+
type=ref,event=branch
38+
type=ref,event=pr
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=semver,pattern={{major}}
42+
type=sha
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v2
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v2
47+
- name: Login to Docker Hub
48+
if: github.event_name != 'pull_request'
49+
uses: docker/login-action@v2
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
- name: Build and push
54+
uses: docker/build-push-action@v4
55+
with:
56+
context: .
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}

{{cookiecutter.project_slug}}/.github/workflows/push.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)