Skip to content

Commit

Permalink
ci(gha): update ci (#138)
Browse files Browse the repository at this point in the history
* ci(gha): upgrade publish ci

* chore: set lint

* ci(gha): add lint ci

* ci(gha): fix poetry

* ci(gha): disable armv7
  • Loading branch information
isac322 authored May 22, 2023
1 parent 811b9a9 commit 14f6158
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 140 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
- name: Lint
run: |
poetry install --no-root --sync
poetry run flake8 .
build:
runs-on: ubuntu-latest
env:
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
DOCKERHUB_USERNAME: isac322
steps:
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.PLATFORMS }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Restore buildkit state
uses: isac322/buildkit-state@v1
with:
buildx-name: ${{ steps.buildx.outputs.name }}

- name: Build
uses: docker/build-push-action@v4
with:
push: false
platforms: ${{ env.PLATFORMS }}
cache-from: type=gha
cache-to: type=gha,mode=min
71 changes: 0 additions & 71 deletions .github/workflows/ci.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: publish

on:
release:
types: [ released ]

jobs:
build_image:
runs-on: ubuntu-latest
env:
PLATFORMS: linux/amd64,linux/arm64/v8 #,linux/arm/v7
DOCKERHUB_USERNAME: isac322
steps:
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
flavor: latest=false
images: ${{ env.DOCKERHUB_USERNAME }}/static-lb
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.PLATFORMS }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
platforms: ${{ env.PLATFORMS }}

- name: Enable buildkit cache
uses: actions/cache@v3
with:
path: /tmp/buildkit-cache/buildkit-state.tar
key: ${{ runner.os }}-buildkit-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-
- name: Load buildkit state from cache
uses: dashevo/gh-action-cache-buildkit-state@v1
with:
builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0
cache-path: /tmp/buildkit-cache
cache-max-size: 8g

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=min
Loading

0 comments on commit 14f6158

Please sign in to comment.