PolicyUniverse Updater - Action #1313
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: "PolicyUniverse Updater - Action" | |
on: | |
schedule: | |
- cron: '15 10 * * *' | |
workflow_dispatch: | |
jobs: | |
Update-Job: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Set up NodeJS | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Download phantomjs | |
run: | | |
pwd &&\ | |
wget -O phantomjs-2.1.1-linux-x86_64.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 &&\ | |
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2 &&\ | |
ls -al | |
- name: Install policyuniverse & updater python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e . | |
pip install -r updater/requirements.txt | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Run the updater | |
env: | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_ROLE_NAME: ${{ secrets.AWS_ROLE_NAME }} | |
id: runupdater | |
run: | | |
cd updater | |
python updater.py > output_summary.txt | |
output_summary=`cat output_summary.txt` | |
output_summary="${output_summary//'%'/'%25'}" | |
output_summary="${output_summary//$'\n'/'%0A'}" | |
output_summary="${output_summary//$'\r'/'%0D'}" | |
echo "::set-output name=updatersummary::$output_summary" | |
rm output_summary.txt | |
mv output_formatted.json ../policyuniverse/data.json | |
cd .. | |
sed -ri "s/(version=\"[0-9]+.[0-9]+.[0-9]+.)([0-9]+)\"/\1`date +"%Y%m%d"`\"/g" setup.py | |
rm -rf phantomjs-2.1.1-linux-x86_64/ | |
rm phantomjs-2.1.1-linux-x86_64.tar.bz2 | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Updating PolicyUniverse SDFs | |
committer: GitHub <noreply@github.com> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
title: 'Updating PolicyUniverse Data.json' | |
body: ${{ steps.runupdater.outputs.updatersummary }} | |
labels: data-update, automated pr | |
assignees: | | |
scriptsrc | |
patricksanders | |
reviewers: | | |
scriptsrc | |
patricksanders | |
draft: false | |
branch: auto_data_update | |
request-to-parent: false | |
- name: Check outputs | |
run: | | |
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}" | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |