Skip to content

Commit 113cfc9

Browse files
ci: Setup GitHub Actions for the project (#17)
As well as update dependabot config.
1 parent 3d8ad5e commit 113cfc9

4 files changed

Lines changed: 165 additions & 22 deletions

File tree

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[{.babelrc,.compressrc,.eslintrc}]
11+
indent_size = 2
12+
13+
[*.{css,cfg,html,ini,js,json,md,service,toml,yaml,yml,xml}]
14+
indent_size = 2
15+
16+
[*.{elm,nginx,py,rst,sh}]
17+
indent_size = 4
18+
19+
[*Makefile*]
20+
indent_style = tab
21+
tab_width = 4
22+
23+
[*.mk]
24+
indent_style = tab
25+
tab_width = 4

.github/dependabot.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
version: 2
22
updates:
3-
- package-ecosystem: docker
4-
directory: "/"
5-
schedule:
6-
interval: monthly
7-
time: "03:00"
8-
open-pull-requests-limit: 10
9-
reviewers:
10-
- playpauseandstop
11-
assignees:
12-
- playpauseandstop
3+
- package-ecosystem: "docker"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
time: "03:00"
8+
open-pull-requests-limit: 10
9+
reviewers:
10+
- "playpauseandstop"
11+
labels:
12+
- "build"
13+
- "dependencies"
14+
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "monthly"
19+
time: "05:00"
20+
open-pull-requests-limit: 10
21+
reviewers:
22+
- "playpauseandstop"
23+
labels:
24+
- "build"
25+
- "dependencies"
26+
- "ci"

.github/workflows/ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
defaults:
2+
run:
3+
shell: "bash"
4+
5+
name: "CI"
6+
7+
on:
8+
push:
9+
branches: ["master"]
10+
tags: ["v*"]
11+
pull_request:
12+
branches: ["master"]
13+
14+
jobs:
15+
build:
16+
name: "Verify that Docker image build well"
17+
18+
runs-on: "ubuntu-latest"
19+
20+
steps:
21+
- uses: "actions/checkout@v2.4.0"
22+
23+
- name: "Cache Docker layers"
24+
uses: "actions/cache@v2.1.6"
25+
with:
26+
path: "/tmp/.buildx-cache"
27+
key: "${{ runner.os }}-buildx-${{ github.sha }}"
28+
restore-keys:
29+
${{ runner.os }}-buildx-
30+
31+
- name: "Login to Docker Hub"
32+
uses: "docker/login-action@v1.10.0"
33+
with:
34+
username: "${{ secrets.DOCKER_HUB_USERNAME }}"
35+
password: "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"
36+
37+
- id: "buildx"
38+
name: "Setup Docker Buildx"
39+
uses: "docker/setup-buildx-action@v1.6.0"
40+
41+
- id: "docker_build"
42+
name: "Build Docker image"
43+
uses: "docker/build-push-action@v2.7.0"
44+
with:
45+
builder: "${{ steps.buildx.outputs.name }}"
46+
context: "./"
47+
file: "./Dockerfile"
48+
push: false
49+
tags: "${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}:latest"
50+
cache-from: "type=local,src=/tmp/.buildx-cache"
51+
cache-to: "type=local,dest=/tmp/.buildx-cache"
52+
53+
- name: "Docker image digest"
54+
run: "echo ${{ steps.docker_build.outputs.digest }}"
55+
56+
deploy:
57+
needs: ["build"]
58+
name: "Push Docker image to the Docker Hub"
59+
if: "${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}"
60+
61+
runs-on: "ubuntu-latest"
62+
63+
steps:
64+
- uses: "actions/checkout@v2.4.0"
65+
66+
- name: "Cache Docker layers"
67+
uses: "actions/cache@v2.1.6"
68+
with:
69+
path: "/tmp/.buildx-cache"
70+
key: "${{ runner.os }}-buildx-${{ github.sha }}"
71+
restore-keys:
72+
${{ runner.os }}-buildx-
73+
74+
- name: "Login to Docker Hub"
75+
uses: "docker/login-action@v1.10.0"
76+
with:
77+
username: "${{ secrets.DOCKER_HUB_USERNAME }}"
78+
password: "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"
79+
80+
- id: "buildx"
81+
name: "Setup Docker Buildx"
82+
uses: "docker/setup-buildx-action@v1.6.0"
83+
84+
- id: "deploy_info"
85+
name: "Setup deploy info"
86+
run: |
87+
set -euo pipefail
88+
89+
base_tag_name="${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}"
90+
tag_name="${base_tag_name}:latest"
91+
92+
if [ "${GITHUB_REF::10}" = "refs/tags/" ]; then
93+
git_tag_name="${GITHUB_REF:10}"
94+
tag_name="${base_tag_name}:${git_tag_name}"
95+
fi
96+
97+
echo "::set-output name=tag_name::${tag_name}"
98+
99+
- id: "docker_build"
100+
name: "Build & push Docker image"
101+
uses: "docker/build-push-action@v2.7.0"
102+
with:
103+
builder: "${{ steps.buildx.outputs.name }}"
104+
context: "./"
105+
file: "./Dockerfile"
106+
push: true
107+
tags: "${{ steps.deploy_info.outputs.tag_name }}"
108+
cache-from: "type=local,src=/tmp/.buildx-cache"
109+
cache-to: "type=local,dest=/tmp/.buildx-cache"
110+
111+
- name: "Docker image digest"
112+
run: "echo ${{ steps.docker_build.outputs.digest }}"

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# docker-python
22

3-
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/playpauseandstop/docker-python.svg)
4-
![Docker Pulls](https://img.shields.io/docker/pulls/playpauseandstop/docker-python.svg)
3+
[![CI](https://github.com/playpauseandstop/docker-python/actions/workflows/ci.yml/badge.svg)](https://github.com/playpauseandstop/docker-python/actions/workflows/ci.yml)
4+
[![Docker Pulls](https://img.shields.io/docker/pulls/playpauseandstop/docker-python.svg)](https://hub.docker.com/r/playpauseandstop/docker-python)
55

6-
Add poetry, pre-commit, and other dev-tools installed via pipx to official
7-
Python slim Docker image.
6+
Add poetry, pre-commit, and other dev-tools installed via pipx to official Python slim Docker image.
87

98
## Usage
109

@@ -33,8 +32,7 @@ FROM playpauseandstop/docker-python:5.0.0
3332

3433
### Python versions
3534

36-
By default, `docker-python` image uses latest stable Python version. But some
37-
other versions supported as well.
35+
By default, `docker-python` image uses latest stable Python version. But some other versions supported as well.
3836

3937
List of supported Python versions are (`<PY_VERSION>` -> base Docker image)
4038

@@ -156,9 +154,3 @@ To run something, using built image:
156154
```bash
157155
make ARGS="..." run
158156
```
159-
160-
To push image (of specific tag):
161-
162-
```bash
163-
make TAG="..." deploy
164-
```

0 commit comments

Comments
 (0)