Skip to content

Commit

Permalink
Merge pull request #6 from Tecnativa/apply-templates
Browse files Browse the repository at this point in the history
Apply templates
  • Loading branch information
joao-p-marques committed Feb 15, 2021
2 parents 3c757c8 + 9067b47 commit c210bd3
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 34 deletions.
10 changes: 10 additions & 0 deletions .copier-answers.autopretty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.1.0
_src_path: https://github.com/copier-org/autopretty.git
ansible: false
biggest_kbs: 1000
github: true
js: false
main_branches:
- master
python: true
15 changes: 15 additions & 0 deletions .copier-answers.image-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.1.3
_src_path: https://github.com/Tecnativa/image-template.git
dockerhub_image: tecnativa/whitelist
image_platforms:
- linux/386
- linux/amd64
main_branches:
- master
project_name: docker-whitelist
project_owner: Tecnativa
push_to_ghcr: true
pytest: false
python_versions:
- "3.9"
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.py]
# For isort
profile = black

[*.{code-snippets,code-workspace,json,yaml,yml}{,.jinja}]
indent_size = 2
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E203, E501, W503, B950
max-line-length = 88
select = C,E,F,W,B
110 changes: 110 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Build, Test & Deploy

"on":
pull_request:
push:
branches:
- master
tags:
- "v*"
workflow_dispatch:

env:
LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8"

jobs:
build-push:
runs-on: ubuntu-20.04
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
DOCKER_IMAGE_NAME: ${{ github.repository }}
DOCKERHUB_IMAGE_NAME: tecnativa/whitelist
PUSH: ${{ toJSON(github.event_name != 'pull_request') }}
steps:
# Set up Docker Environment
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
/tmp/.buildx-cache
key: buildx|${{ secrets.CACHE_DATE }}|${{ runner.os }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
install: true
# Build and push
- name: Docker meta for local images
id: docker_meta_local
uses: crazy-max/ghaction-docker-meta@v1
with:
images: localhost:5000/${{ env.DOCKER_IMAGE_NAME }}
tag-edge: true
tag-semver: |
{{version}}
{{major}}
{{major}}.{{minor}}
- name: Build and push to local (test) registry
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: |
linux/386
linux/amd64
load: false
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: ${{ steps.docker_meta_local.outputs.labels }}
tags: ${{ steps.docker_meta_local.outputs.tags }}
# Next jobs only happen outside of pull requests and on main branches
- name: Login to DockerHub
if: ${{ fromJSON(env.PUSH) }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ fromJSON(env.PUSH) }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.BOT_LOGIN }}
password: ${{ secrets.BOT_TOKEN }}
- name: Docker meta for public images
if: ${{ fromJSON(env.PUSH) }}
id: docker_meta_public
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
ghcr.io/${{ env.DOCKER_IMAGE_NAME }}
${{ env.DOCKERHUB_IMAGE_NAME }}
tag-edge: true
tag-semver: |
{{version}}
{{major}}
{{major}}.{{minor}}
- name: Build and push to public registry(s)
if: ${{ fromJSON(env.PUSH) }}
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: |
linux/386
linux/amd64
load: false
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: ${{ steps.docker_meta_public.outputs.labels }}
tags: ${{ steps.docker_meta_public.outputs.tags }}
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on:
pull_request:
push:
branches:
- master

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
Loading

0 comments on commit c210bd3

Please sign in to comment.