Skip to content

Commit

Permalink
👷Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
7rikazhexde committed Jan 4, 2025
1 parent 80e728b commit 7c5a1e1
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 28 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
groups:
dependencies:
patterns:
- "*"
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
groups:
dependencies:
patterns:
- "*"
open-pull-requests-limit: 10
19 changes: 12 additions & 7 deletions .github/workflows/push_gh-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@

name: ci
on:
# 直接プッシュ時([skip ci]がないもの)
push:
branches:
- main
# 他のワークフローの完了時
workflow_run:
workflows:
- "Update pre-commit Hooks"
- "Update Requirements after Dependabot Merge"
types:
- completed
branches:
- main

env:
cache_id: ""
Expand All @@ -15,6 +25,8 @@ permissions:

jobs:
deploy:
# 条件分岐の整理
if: (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')) || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -34,10 +46,3 @@ jobs:
run: poetry install
- name: Deploy GitHub Pages
run: poetry run mkdocs gh-deploy --force
#- run: |
# pip install mkdocs-material \
# mkdocs-static-i18n \
# pygments \
# plantuml-markdown \
# mkdocs-glightbox
#- run: mkdocs gh-deploy --force
51 changes: 51 additions & 0 deletions .github/workflows/update_pre-commit_hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Update pre-commit Hooks

on:
schedule:
- cron: "0 0 * * 5"
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
token: ${{ secrets.PAT_FOR_PUSHES }}
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.13"
- name: Install poetry
run: pip install poetry
- name: Cache dependencies
uses: actions/[email protected]
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install

# Update pre-commit hooks and check for changes
- name: Update pre-commit hooks
id: update_hooks
run: |
poetry run pre-commit autoupdate
if git diff --exit-code .pre-commit-config.yaml; then
echo "has_updates=false" >> "$GITHUB_OUTPUT"
echo "No updates to pre-commit hooks. Exiting workflow."
else
echo "has_updates=true" >> "$GITHUB_OUTPUT"
fi
# Commit/push
- name: Commit changes
if: steps.update_hooks.outputs.has_updates == 'true'
shell: bash
run: |
git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .pre-commit-config.yaml
git commit -m ":arrow_up: Update pre-commit hooks [skip ci]" || echo "No changes to commit"
git push
42 changes: 42 additions & 0 deletions .github/workflows/update_requirements_after_dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update Requirements after Dependabot Merge

# ワークフローの処理の流れ:
# 1. トリガー条件:
# - プルリクエストマージ時
# - Dependabotによる実行であること
# 2. 環境のセットアップ(Ubuntu、Python、Poetry)
# 3. requirements.txtとrequirements-dev.txtの作成
# 4. 変更のコミットとプッシュ

on:
pull_request:
types: [closed]

jobs:
update-requirements:
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
token: ${{ secrets.PAT_FOR_PUSHES }}
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.13"
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Update requirements files
run: |
poetry export -f requirements.txt -o requirements.txt --without-hashes
poetry export -f requirements.txt -o requirements-dev.txt --without-hashes --with dev
- name: Commit and push changes
run: |
git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add requirements.txt requirements-dev.txt
git commit -m ":wrench:Update requirements files after dependency update [skip ci]" || echo "No changes to commit"
git push
87 changes: 87 additions & 0 deletions .github/workflows/update_version_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Version Update and Release

# Workflow Process Flow:
# 1. Trigger Conditions:
# - Manual execution (workflow_dispatch)
# 2. Environment Setup (Ubuntu, Python, Poetry)
# 3. Retrieve the current version
# 4. Update to the new version (patch, minor, or major)
# 5. Commit and push the changes
# 6. Create and push a new tag
# 7. Generate the changelog
# 8. Create a GitHub release

on:
workflow_dispatch:
inputs:
update_type:
description: "Type of version update"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major

jobs:
update-version-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
token: ${{ secrets.PAT_FOR_PUSHES }}
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.13"
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Get current version
id: current_version
run: echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
- name: Update version
id: update_version
run: |
poetry version ${{ github.event.inputs.update_type }}
echo "new_version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
- name: Commit and push if changed
run: |
git add pyproject.toml
git commit -m ":wrench:Bump version to ${{ steps.update_version.outputs.new_version }}" || echo "No changes to commit"
git push
- name: Create and push new tag
run: |
git tag v${{ steps.update_version.outputs.new_version }}
git push --tags
- name: Generate changelog
id: changelog
run: |
changelog=$(git log --pretty=format:"- %s" v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }})
{
echo "changelog<<EOF"
echo "$changelog"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/[email protected]
with:
tag_name: v${{ steps.update_version.outputs.new_version }}
name: repo-dispatch-event-sender-v${{ steps.update_version.outputs.new_version }}
body: |
## Changes in this Release
${{ steps.changelog.outputs.changelog }}
For full changes, see the [comparison view](${{ github.server_url }}/${{ github.repository }}/compare/v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }})
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_PUSHES }}
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ regex==2024.11.6 ; python_version >= "3.10" and python_version < "4.0"
requests==2.32.3 ; python_version >= "3.10" and python_version < "4.0"
ruamel-yaml-clib==0.2.12 ; platform_python_implementation == "CPython" and python_version < "3.13" and python_version >= "3.10"
ruamel-yaml==0.17.40 ; python_version >= "3.10" and python_version < "4.0"
ruff==0.8.5 ; python_version >= "3.10" and python_version < "4.0"
ruff==0.8.6 ; python_version >= "3.10" and python_version < "4.0"
six==1.17.0 ; python_version >= "3.10" and python_version < "4.0"
taskipy==1.14.1 ; python_version >= "3.10" and python_version < "4.0"
tomli==2.2.1 ; python_version >= "3.10" and python_version < "4.0"
Expand Down

0 comments on commit 7c5a1e1

Please sign in to comment.