2022-01-11 20:31:18 +00:00
|
|
|
---
|
2022-02-28 05:40:45 +00:00
|
|
|
name: Update the software lists
|
2022-01-11 20:31:18 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- develop
|
|
|
|
|
|
|
|
env:
|
|
|
|
PIP_CACHE_DIR: ~/.cache/pip
|
2022-02-28 05:40:45 +00:00
|
|
|
TESTING_BRANCH_BASE: testing/update_software_lists
|
2022-01-11 20:31:18 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
setup:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
# Commit author information for git
|
|
|
|
git_author: ${{ steps.git-config.outputs.author }}
|
|
|
|
git_email: ${{ steps.git-config.outputs.email }}
|
|
|
|
git_user: ${{ steps.git-config.outputs.user }}
|
|
|
|
# The name of the branch used for testing
|
|
|
|
testing_branch: ${{ steps.testing-branch.outputs.name }}
|
|
|
|
steps:
|
|
|
|
- id: git-config
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=author::$GIT_USER <$GIT_EMAIL>"
|
|
|
|
echo "::set-output name=email::$GIT_EMAIL"
|
|
|
|
echo "::set-output name=user::$GIT_USER"
|
|
|
|
env:
|
|
|
|
GIT_EMAIL: ${{ fromJson(secrets.GIT_AUTHOR_INFORMATION).user.email }}
|
|
|
|
GIT_USER: ${{ fromJson(secrets.GIT_AUTHOR_INFORMATION).user.name }}
|
|
|
|
- id: testing-branch
|
|
|
|
run: echo "::set-output name=name::$BASE_BRANCH/$COMMIT_SHA"
|
|
|
|
env:
|
|
|
|
BASE_BRANCH: ${{ env.TESTING_BRANCH_BASE }}
|
|
|
|
COMMIT_SHA: ${{ github.sha }}
|
2022-02-28 05:40:45 +00:00
|
|
|
generate_updates:
|
2022-01-11 20:31:18 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: setup
|
|
|
|
outputs:
|
|
|
|
# If changes are detected then a commit will have been pushed
|
2022-02-28 05:40:45 +00:00
|
|
|
has_updates: ${{ steps.commit-for-testing.outputs.changes_detected }}
|
2022-01-11 20:31:18 +00:00
|
|
|
# Don't run if we're seeing an update push
|
|
|
|
if: github.actor != needs.setup.outputs.git_user
|
|
|
|
steps:
|
2022-04-08 20:44:54 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-11 20:31:18 +00:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.CISAGOVBOT_PAT }}
|
|
|
|
- id: setup-python
|
2022-04-08 20:44:54 +00:00
|
|
|
uses: actions/setup-python@v3
|
2022-01-11 20:31:18 +00:00
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
2022-04-08 20:44:54 +00:00
|
|
|
- uses: actions/cache@v3
|
2022-01-11 20:31:18 +00:00
|
|
|
env:
|
|
|
|
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
|
|
|
|
py${{ steps.setup-python.outputs.python-version }}-"
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
${{ env.PIP_CACHE_DIR }}
|
|
|
|
key: "${{ env.BASE_CACHE_KEY }}\
|
2022-02-28 05:40:45 +00:00
|
|
|
${{ hashFiles('.github/workflows/update_software_lists.yml') }}-\
|
2022-01-11 20:31:18 +00:00
|
|
|
${{ hashFiles('config/requirements.txt') }}"
|
|
|
|
restore-keys: |
|
|
|
|
${{ env.BASE_CACHE_KEY }}
|
|
|
|
- name: Update Python base packages
|
|
|
|
run: python -m pip install --upgrade pip setuptools wheel
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pip install --upgrade --requirement config/requirements.txt
|
|
|
|
- name: Create the branch for test validation
|
|
|
|
run: git switch --create ${{ needs.setup.outputs.testing_branch }}
|
2022-02-28 05:29:57 +00:00
|
|
|
- name: Update the YAML and Markdown files as appropriate
|
|
|
|
run: config/update_software_lists.sh
|
2022-01-11 20:31:18 +00:00
|
|
|
- id: commit-for-testing
|
|
|
|
uses: stefanzweifel/git-auto-commit-action@v4
|
|
|
|
with:
|
|
|
|
branch: ${{ needs.setup.outputs.testing_branch }}
|
2022-02-28 05:29:57 +00:00
|
|
|
commit_message: Normalize YAML files and update the software lists
|
2022-01-11 20:31:18 +00:00
|
|
|
commit_user_name: ${{ needs.setup.outputs.git_user }}
|
|
|
|
commit_user_email: ${{ needs.setup.outputs.git_email }}
|
|
|
|
commit_author: ${{ needs.setup.outputs.git_author }}
|
2022-02-28 05:29:57 +00:00
|
|
|
file_pattern: data/cisagov*.yml software_lists/software_list_*.md
|
2022-02-28 05:40:45 +00:00
|
|
|
merge_updates:
|
2022-01-11 20:31:18 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- setup
|
2022-02-28 05:40:45 +00:00
|
|
|
- generate_updates
|
|
|
|
if: needs.generate_updates.outputs.has_updates == 'true'
|
2022-01-11 20:31:18 +00:00
|
|
|
steps:
|
2022-04-08 20:44:54 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-11 20:31:18 +00:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.CISAGOVBOT_PAT }}
|
|
|
|
- name: Configure git
|
|
|
|
run: |
|
|
|
|
git config user.name "${{ needs.setup.outputs.git_user }}"
|
|
|
|
git config user.email "${{ needs.setup.outputs.git_email }}"
|
2022-11-09 17:06:48 +00:00
|
|
|
- uses: lewagon/wait-on-check-action@v1.2.0
|
2022-01-11 20:31:18 +00:00
|
|
|
with:
|
|
|
|
check-name: lint
|
|
|
|
ref: ${{ needs.setup.outputs.testing_branch }}
|
|
|
|
repo-token: ${{ github.token }}
|
|
|
|
- name: Merge the testing branch
|
|
|
|
run: |
|
|
|
|
git fetch
|
|
|
|
git merge origin/${{ needs.setup.outputs.testing_branch }}
|
|
|
|
git push
|
|
|
|
- name: Cleanup testing branch
|
|
|
|
run: git push --delete origin ${{ needs.setup.outputs.testing_branch }}
|