Skip to content

Commit

Permalink
feat: action
Browse files Browse the repository at this point in the history
  • Loading branch information
JinnLynn committed Jun 13, 2024
1 parent 3f6eb20 commit 5f11e0e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 68 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/build-dev.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build
on:
workflow_dispatch:
inputs:
branch:
type: choice
options:
- dev
- master
default: "dev"
required: true
env:
platform: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
defaults:
run:
shell: bash
working-directory: ./
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- uses: mikefarah/yq@master
id: get_version
with:
cmd: "yq -p toml -oy '.project.version' pyproject.toml"
- if: ${{ inputs.branch == 'master' }}
name: Build Docker From master
run: |
docker buildx build --push --platform "${{ env.platform }}" \
-t ${{ secrets.DOCKER_USER }}/genpac \
-t ${{ secrets.DOCKER_USER }}/genpac:${{steps.get_version.outputs.result}} \
.
- if: ${{ inputs.branch == 'dev' }}
name: Build Docker From dev
run: |
docker buildx build --push --platform "${{ env.platform }}" \
-t ${{ secrets.DOCKER_USER }}/genpac:dev .
42 changes: 42 additions & 0 deletions .github/workflows/cook-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: cook-branch
on:
workflow_call:
inputs:
branch:
type: string
default: master
required: true
jobs:
cooking:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
path: work
- name: Checkout Branch cooked
uses: actions/checkout@v4
with:
ref: cooked
path: cooked
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: fire
run: |
pip install ./work/ && \
mkdir -p ./cooked/${{ inputs.branch }} && \
cd ./cooked/${{ inputs.branch }} && \
rm -rf * && \
DEST=. genpac --config=../../work/example/config.ini && \
ls -alhR ./
- name: commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./cooked
commit_message: update
add_options: '-A'
push_options: '--force'
45 changes: 11 additions & 34 deletions .github/workflows/cook.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
name: cook
on:
workflow_dispatch:
workflow_call:
schedule:
- cron: "0 */12 * * *"
push:
branches:
- dev-hot

jobs:
cooking:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Branch dev
uses: actions/checkout@v4
with:
ref: dev
path: dev
- name: Checkout Branch cooked
uses: actions/checkout@v4
with:
ref: cooked
path: cooked
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: fire
run: |
pip install ./dev/ && \
mkdir ./temp && \
DEST=./temp genpac --config=./dev/example/config.ini
- name: clean and copy
run: |
find ./cooked -maxdepth 1 -type f -name "*.*" ! -name "README.md" ! -name ".gitignore" -delete && \
cp ./temp/* ./cooked/
- name: commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./cooked
commit_message: update
push_options: '--force'
master:
uses: ./.github/workflows/cook-branch.yml
with:
branch: master
dev:
uses: ./.github/workflows/cook-branch.yml
with:
branch: dev

0 comments on commit 5f11e0e

Please sign in to comment.