Update AWS IAM Managed Policies data #450
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: Update AWS IAM Managed Policies data | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run everyday at 4AM UTC | |
- cron: '0 4 * * *' | |
jobs: | |
gather_and_update_iam_managed_policy_data: | |
name: Gather the latest AWS IAM Managed Policy data and if there is new data, publish a new package version to npm | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Gather data and check for changes | |
id: gatherData | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Install dependencies | |
npm i | |
# Gather data | |
npm run gather-managed-policies | |
# Setup git repo | |
git config --global user.name 'TobiLG' | |
git config --global user.email 'tobilg@users.noreply.github.com' | |
git remote set-url --push origin https://tobilg:$GITHUB_TOKEN@github.com/tobilg/aws-iam-managed-policies | |
# Add new files if there are any | |
git add . | |
# Check for changes and commit if there are any | |
git diff-index --cached --quiet HEAD || echo '::set-output name=changed::true' | |
- name: Eventually publish new package version | |
if: ${{ steps.gatherData.outputs.changed == 'true' }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
# Increase package patch version | |
npm --no-git-tag-version version patch | |
# Add new files | |
git add . | |
# Commit changes | |
git commit -am "[no ci] Data update on $(date '+%FT%H:%M:%S')" | |
# Push to repo | |
git push | |
# Build package sources | |
npm run build | |
# Publish new version to npm registry | |
npm publish | |
publish_github_pages: | |
name: Publish GitHub Pages | |
needs: | |
- gather_and_update_iam_managed_policy_data | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Pages | |
uses: actions/configure-pages@v1 | |
- name: Generate docs for GitHub Pages | |
run: | | |
# Install dependencies | |
npm i | |
# Build package sources | |
npm run build | |
# Generate docs | |
npm run generate-docs | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: './docs' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |