Skip to content

Commit

Permalink
Merge pull request #2555 from Kaiserdragon2/WorkflowRework
Browse files Browse the repository at this point in the history
Workflow rework
  • Loading branch information
Kaiserdragon2 authored Feb 2, 2025
2 parents 0e38f09 + be339a0 commit cae9835
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 78 deletions.
193 changes: 172 additions & 21 deletions .github/workflows/BuildPages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,81 @@ on:
paths:
- 'newicons/appfilter.xml'
push:
branches: ['Arcticons-Pages']
branches: ['Arcticons-Pages','main']
paths:
- 'docs/**'
- 'newicons/appfilter.xml'
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '30 5 * * 0,3'
workflow_dispatch:
inputs:
run_colormapping:
description: "Run Create_Colormappping job (true/false)"
description: "Run Create_Colormappping job"
type: boolean
required: false
default: "true"
default: false
run_requestjson:
description: "Run Create_requestjson job (true/false)"
description: "Run Create_requestjson job"
type: boolean
required: false
default: false
run_Request_Update:
description: "Run Update_Requests job"
type: boolean
required: false
default: "true"
env:
Branch: Arcticons-Pages
default: false
run_fetch_and_push_file:
description: "Run fetch_and_push_file job"
type: boolean
required: false
default: false

jobs:
fetch_and_push_file:
name: Fetch and Push File
if: ${{ github.repository == vars.REPOSITORY && ((github.event_name == 'push' && github.ref_name == vars.MAIN_BRANCH) || (github.event_name == 'workflow_dispatch' && inputs.run_fetch_and_push_file == true)) }}
runs-on: ubuntu-latest
concurrency:
group: push
cancel-in-progress: false
environment:
name: FileSync
env:
SOURCE_BRANCH: ${{vars.MAIN_BRANCH}}
TARGET_BRANCH: ${{vars.PAGES_BRANCH}}
FILE_PATH: newicons/appfilter.xml

steps:
# Step 1: Checkout the repository
- name: Checkout main Repository
uses: actions/checkout@v4
with:
ref: ${{vars.MAIN_BRANCH}}
path: main

# Step 2: Checkout the 2. repository
- name: Checkout Arcticons-Pages Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
path: pages
# Step 3: Fetch the file from the source branch
- name: Copy File from main to Arcticons-Pages
run: |
rm pages/newicons/appfilter.xml
cp main/newicons/appfilter.xml pages/newicons/appfilter.xml
# Step 4: Commit and push changes
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd pages
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add $FILE_PATH
git commit -m "Update $FILE_PATH from $SOURCE_BRANCH to $TARGET_BRANCH"
git push
check_appfilter:
name: Check appfilter.xml from pull_request
if: github.event_name == 'pull_request_target'
Expand Down Expand Up @@ -61,9 +120,83 @@ jobs:
gh pr comment ${{ github.event.pull_request.number }} --body-file comment_markdown.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Update_Requests:
if: ${{ github.repository == vars.REPOSITORY && ( inputs.run_Request_Update == true || github.event_name == 'schedule') && vars.AUTOMATIC_UPDATE == 'true' }}
environment:
name: Request-Update
concurrency:
group: 'push'
cancel-in-progress: false
runs-on: ubuntu-latest
outputs:
changes_detected: ${{ steps.check_changes.outputs.changes_detected }}
request_changes: ${{ steps.check_changes.outputs.Request_changes }}
image_changes: ${{ steps.check_changes.outputs.Image_changes }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUEST_LIMIT: ${{ vars.REQUEST_LIMIT }}
MONTHS_LIMIT: ${{ vars.MONTHS_LIMIT }}
MIN_REQUESTS: ${{ vars.MIN_REQUESTS }}
SUBJECT_PREFIX: ${{ vars.SUBJECT_PREFIX }}
SUBJECT_SUFFIX: ${{ vars.SUBJECT_SUFFIX }}
IMAP_SERVER: ${{ secrets.IMAP_SERVER }}
IMAP_USERNAME: ${{ secrets.IMAP_USERNAME }}
IMAP_PASSWORD: ${{ secrets.IMAP_PASSWORD }}
run: |
mkdir mail
python .github/workflows/email_parser_auto.py mail newicons/appfilter.xml docs/extracted_png docs/assets/
rm -r mail
- name: Check for changes
id: check_changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
# Get the list of changed files
CHANGED_FILES=$(git diff --cached --name-only)
# Check if there are any changes
if [ -z "$CHANGED_FILES" ]; then
echo "No changes detected"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "changes_detected=true" >> $GITHUB_OUTPUT
# Set different outputs depending on which path changed
if echo "$CHANGED_FILES" | grep -q "^docs/assets/requests.txt"; then
echo "Request_changes=true" >> $GITHUB_OUTPUT
fi
if echo "$CHANGED_FILES" | grep -q "^docs/extracted_png/"; then
echo "Image_changes=true" >> $GITHUB_OUTPUT
fi
# You can add more checks for other directories or files here as needed
fi
- name: Commit and Push if Changes Exist
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }}
run: |
git commit -m "Automated Request Update"
git push
Check_FilePath:
name: Check File Path changes
if: ${{ github.event_name == 'push'}}
if: ${{github.event_name == 'push' && github.ref_name == vars.PAGES_BRANCH}}
runs-on: ubuntu-latest
outputs:
imagechange: ${{ steps.changes.outputs.images }}
Expand All @@ -72,7 +205,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{env.Branch}}
ref: ${{vars.PAGES_BRANCH}}
- uses: dorny/paths-filter@v3
id: changes
with:
Expand All @@ -81,11 +214,11 @@ jobs:
- 'docs/extracted_png/**'
requests:
- 'docs/assets/requests.txt'
base: ${{env.Branch}}
base: ${{vars.PAGES_BRANCH}}
Create_Colormappping:
name: Create Colormapping
needs: [Check_FilePath]
if: ${{ ((needs.Check_FilePath.outputs.imagechange == 'true' && github.event_name == 'push') || inputs.run_colormapping == 'true' ) && !failure() }}
needs: [Check_FilePath, Update_Requests]
if: ${{ ((needs.Check_FilePath.outputs.imagechange == 'true' && github.event_name == 'push') || (((github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && needs.Update_Requests.outputs.image_changes == 'true') || (inputs.run_colormapping == true && inputs.run_Request_Update == false ))) && !failure() }}
runs-on: ubuntu-latest
concurrency:
group: 'colormapping'
Expand All @@ -94,7 +227,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{env.Branch}}
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -114,8 +247,8 @@ jobs:
path: docs/assets/image_color_counts.xml
Create_requestjson:
name: Create Requestjson
needs: [Check_FilePath]
if: ${{ ((needs.Check_FilePath.outputs.requestchange == 'true' && github.event_name == 'push') || inputs.run_requestjson == 'true' ) && !failure() }}
needs: [Check_FilePath, Update_Requests]
if: ${{ ((needs.Check_FilePath.outputs.requestchange == 'true' && github.event_name == 'push') || (((github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && needs.Update_Requests.outputs.request_changes == 'true') || (inputs.run_requestjson == true && inputs.run_Request_Update == false ))) && !failure() }}
runs-on: ubuntu-latest
concurrency:
group: 'requestjson'
Expand All @@ -126,7 +259,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{env.Branch}}
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -149,28 +282,46 @@ jobs:
runs-on: ubuntu-latest
concurrency:
group: 'push'
cancel-in-progress: false
if: ${{(needs.Create_Colormappping.result == 'success' || needs.Create_requestjson.result == 'success') && !failure()}}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{env.Branch}}
ref: ${{vars.PAGES_BRANCH}}
- name: Download Colormapping and Requestjson
uses: actions/download-artifact@v4
with:
path: docs/assets
merge-multiple: true
- name: Commit and Push Changes
- name: Check for changes
id: check_changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
# Get the list of changed files
CHANGED_FILES=$(git diff --cached --name-only)
# Check if there are any changes
if [ -z "$CHANGED_FILES" ]; then
echo "No changes detected"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi
- name: Commit and Push if Changes Exist
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }}
run: |
git commit -m "Automated updates from Colormappping and Requestjson jobs"
git push
parse_and_combine:
name: Parse and Combine Appfilter
needs: [check_appfilter, Push_Files]
if: '!failure()'
needs: [check_appfilter, Push_Files,fetch_and_push_file,Update_Requests]
if: ${{(needs.check_appfilter.result == 'success' || needs.Push_Files.result == 'success' || needs.fetch_and_push_file.result == 'success' ||(needs.Update_Requests.result == 'success' && needs.Update_Requests.outputs.changes_detected == 'true' )) && !failure()}}
permissions:
pages: write # Required to deploy to GitHub Pages
id-token: write # Required to deploy to GitHub Pages
Expand All @@ -185,7 +336,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{env.Branch}}
ref: ${{vars.PAGES_BRANCH}}
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/fetch-and-push.yml

This file was deleted.

0 comments on commit cae9835

Please # to comment.