mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-03 11:34:27 +02:00
Refactor workflows
- Update webpack.yml and deploy-docs.yml to use GitHub App tokens - Ensure consistent token usage for all git operations - Add proper checkout configuration with fetch-depth - Standardize environment variables and job structure - Add timeouts to prevent hanging workflows - Improve change detection for relevant files
This commit is contained in:
40
.github/workflows/deploy-docs.yml
vendored
40
.github/workflows/deploy-docs.yml
vendored
@@ -12,19 +12,18 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-for-docs-changes:
|
check-for-changes:
|
||||||
name: Check for Docs Changes
|
name: Check for changes
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
# Output a boolean indicating if any relevant files have changed
|
changed: ${{ steps.check_files.outputs.any_changed }}
|
||||||
docs_changed: ${{ steps.check_files.outputs.any_changed }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check for changed files in docs folder or mkdocs.yml
|
- name: Check for changed documentation files
|
||||||
id: check_files
|
id: check_files
|
||||||
uses: tj-actions/changed-files@v46
|
uses: tj-actions/changed-files@v46
|
||||||
with:
|
with:
|
||||||
@@ -35,22 +34,39 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
name: Deploy MkDocs Site
|
name: Deploy MkDocs Site
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: check-for-docs-changes
|
timeout-minutes: 10
|
||||||
if: needs.check-for-docs-changes.outputs.docs_changed == 'true'
|
needs: check-for-changes
|
||||||
|
if: needs.check-for-changes.outputs.changed == 'true'
|
||||||
|
env:
|
||||||
|
CI_COMMIT_AUTHOR: 'CI Bot'
|
||||||
|
CI_COMMIT_EMAIL: 'ci@noreply.github.com'
|
||||||
|
CI_COMMIT_MESSAGE: 'Continuous Integration - Deploy Documentation'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Generate GitHub App Token
|
||||||
|
id: generate_token
|
||||||
|
uses: tibdex/github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.APP_ID }}
|
||||||
|
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x' # Use a specific version like '3.10', '3.11', or '3.12'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install MkDocs, Material for MkDocs, and PyMdown Extensions
|
- name: Install MkDocs and dependencies
|
||||||
run: pip install mkdocs mkdocs-material pymdown-extensions
|
run: pip install mkdocs mkdocs-material pymdown-extensions
|
||||||
|
|
||||||
- name: Deploy Docs to GitHub Pages
|
- name: Deploy Docs to GitHub Pages
|
||||||
run: mkdocs gh-deploy --force --clean
|
run: |
|
||||||
env:
|
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
||||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
|
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
|
||||||
|
git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/DigiLive/mushroom-strategy.git
|
||||||
|
mkdocs gh-deploy --force --clean --message "${{ env.CI_COMMIT_MESSAGE }}"
|
||||||
|
39
.github/workflows/webpack.yml
vendored
39
.github/workflows/webpack.yml
vendored
@@ -6,19 +6,18 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
detect-source-changes:
|
check-for-changes:
|
||||||
name: Detect Source Changes
|
name: Check for changes
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
source_changed: ${{ steps.check_files.outputs.any_changed }}
|
changed: ${{ steps.check_files.outputs.any_changed }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
|
|
||||||
|
|
||||||
- name: Check for changed files in src or webpack.config.js
|
- name: Check for changed source files
|
||||||
id: check_files
|
id: check_files
|
||||||
uses: tj-actions/changed-files@v46
|
uses: tj-actions/changed-files@v46
|
||||||
with:
|
with:
|
||||||
@@ -29,43 +28,51 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build Distribution
|
name: Build Distribution
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
needs: check-for-changes
|
||||||
|
if: needs.check-for-changes.outputs.changed == 'true'
|
||||||
env:
|
env:
|
||||||
|
CI_COMMIT_AUTHOR: 'CI Bot'
|
||||||
|
CI_COMMIT_EMAIL: 'ci@noreply.github.com'
|
||||||
CI_COMMIT_MESSAGE: |
|
CI_COMMIT_MESSAGE: |
|
||||||
Continuous Integration - Build Distribution
|
Continuous Integration - Build Distribution
|
||||||
|
|
||||||
[skip codacy]
|
[skip codacy]
|
||||||
CI_COMMIT_AUTHOR: Continuous Integration
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [22.x]
|
node-version: [22.x]
|
||||||
|
|
||||||
needs: detect-source-changes
|
|
||||||
if: needs.detect-source-changes.outputs.source_changed == 'true'
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Generate GitHub App Token
|
||||||
|
id: generate_token
|
||||||
|
uses: tibdex/github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.APP_ID }}
|
||||||
|
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# Build steps
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Node Install
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Build Distribution
|
- name: Build Distribution
|
||||||
run: |
|
run: npm run build
|
||||||
npm run build
|
|
||||||
|
|
||||||
- name: Commit Distribution Build
|
- name: Commit Distribution Build
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
||||||
git config --global user.email "ci_activity@noreply.github.com"
|
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
|
||||||
|
git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/DigiLive/mushroom-strategy.git
|
||||||
git add dist
|
git add dist
|
||||||
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
|
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
|
||||||
git push
|
git push
|
||||||
|
Reference in New Issue
Block a user