Skip to content

ci: Fix matrix

ci: Fix matrix #20

name: Daily Analysis Phylum
on:
# schedule:
# # Runs at 14:00 UTC every day
# - cron: '0 14 * * *'
push:
branches:
- DO-2628
jobs:
get_phylum_branches_to_analyze:
name: Get Branches to analyze with phylum
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.set_matrix.outputs.branches }}
steps:
- name: Checkout repository
uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Get branches
id: get_branches
uses: RDXWorks-actions/github-script@main
with:
script: |
let branches = [];
let page = 1;
while (true) {
const response = await github.rest.repos.listBranches({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
page: page,
});
branches = branches.concat(response.data);
if (response.data.length < 100) break;
page++;
}
const branchNames = branches
.map(branch => branch.name)
.filter(name => name === 'DO-2628' || name.startsWith('release/'));
return JSON.stringify(branchNames);
- name: Set branches matrix
id: set_matrix
run: |
echo "branches=${{ steps.get_branches.outputs.result }}" >> $GITHUB_OUTPUT
analyze_branch_phylum:
name: Analyze dependencies with Phylum
needs:
- get_phylum_branches_to_analyze
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
strategy:
matrix:
branch: ${{ fromJson(needs.get_phylum_branches_to_analyze.outputs.branches) }}
steps:
- uses: RDXWorks-actions/checkout@main
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- uses: RDXWorks-actions/setup-python@main
with:
python-version: 3.10.6
- name: Install Phylum
run: |
curl https://sh.phylum.io/ | sh -s -- --yes
# Add the Python user base binary directory to PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run Phylum Analysis
env:
PHYLUM_API_KEY: ${{ secrets.PHYLUM_API_KEY }}
run: phylum analyze --quiet --label ${{ matrix.branch }}_branch_daily_schedule > /dev/null 2>&1 ||
if [ $? -eq 100 ]; then
echo "Phylum Analysis returned exit code 100, but continuing.";
exit 0;
else
exit $?;
fi