testing pipeline #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and update licenses | ||
on: | ||
push: | ||
branches: [ "*-software.eessi.io" ] | ||
pull_request: | ||
branches: [ "*-software.eessi.io" ] | ||
permissions: | ||
contents: write # set permissions for writing | ||
jobs: | ||
license_update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout out software-layer repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
- name: Set up Python | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c | ||
with: | ||
python-version: '3.9' | ||
- name: Run license script and generate patch | ||
id: check_licenses | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
python update_licenses.py --source=pypi TensorFlow | ||
python update_licenses.py --source=github:easybuilders/easybuild EasyBuild | ||
if [ -f license_update.patch ] && [ -s license_update.patch ]; then | ||
PATCH_CONTENT=$(cat license_update.patch) | ||
echo "patch=$PATCH_CONTENT" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create a PR (if changes detected) | ||
id: create_pull_request | ||
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 | ||
if: steps.check_licenses.outputs.patch != '' | ||
with: | ||
commit-message: "Auto PR: Update licenses" | ||
title: "Auto PR: Update licenses" | ||
body: ${{ steps.check_licenses.outputs.patch }} | ||
branch: update-licenses-${{ github.run_number }} | ||
base: [ "*-software.eessi.io" ] | ||
- name: Apply patch (if no PR created) | ||
if: steps.create_pull_request.outputs.number == '' && steps.check_licenses.outputs.patch != '' | ||
run: | | ||
if [ -f license_update.patch ] && [ -s license_update.patch ]; then | ||
git apply license_update.patch | ||
else | ||
echo "No changes to apply" | ||
fi | ||
git add licenses.json | ||
git diff --cached --exit-code || git commit -m "Update licenses.json" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |