Skip to content

Commit

Permalink
Publish filters in parallel (#207)
Browse files Browse the repository at this point in the history
* Publish filters in parallel.

* Restrict workflow to main branch only

This commit modifies the .github/workflows/publish-filter.yml by restricting the generate and create filters steps to only run if the GitHub reference is the main branch. This change was made to refine the CI/CD pipeline, ensuring that the steps run only for changes to the main branch, thus preventing unnecessary runs for branches that don't yet need these procedures.
  • Loading branch information
henrikwidlund committed Aug 13, 2023
1 parent 4374d46 commit 73aa46a
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/publish-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.ref == 'refs/heads/main'

steps:
- name: Setup .NET
Expand All @@ -35,24 +36,31 @@ jobs:
curl -sL $(curl -s https://api.github.com/repos/henrikwidlund/HostsParser/releases/latest | grep browser_download_url | cut -d\" -f4 | grep 'linux-x64.tar.gz$') | tar zx
- name: Create public directory
if: github.ref == 'refs/heads/main'
run: mkdir ./public

- name: Create filters
if: github.ref == 'refs/heads/main'
run: |
cd ./artifacts
for filename in ./Configurations/*.json; do
cp $filename ../artifacts/appsettings.json
dotnet HostsParser.dll
CONFIG_FILE=$(echo $filename | cut -d'/' -f 3)
CONFIG=${CONFIG_FILE//json/txt}
# Default filter doesn't map to the file name of the config, it's just "filter.txt"
if [[ ! -f "$CONFIG" ]]; then
CONFIG="filter.txt"
fi
cp $CONFIG ../public/$CONFIG
done
cat << EOF > temp_script.sh
#!/bin/bash
process_config() {
filename="\$1"
dotnet ./artifacts/HostsParser.dll "\$1"
CONFIG_FILE=\$(echo "\$filename" | cut -d'/' -f 3)
CONFIG=\${CONFIG_FILE//json/txt}
if [[ ! -f "\$CONFIG" ]]; then
CONFIG="filter.txt"
fi
cp "\$CONFIG" ../public/"\$CONFIG"
}
process_config \$1
EOF
chmod +x temp_script.sh
find ./Configurations -name '*.json' -print0 | xargs -0 -I{} -P4 ./temp_script.sh "{}"
rm temp_script.sh
- name: Setup Pages
uses: actions/configure-pages@v3
Expand Down

0 comments on commit 73aa46a

Please sign in to comment.