-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (87 loc) · 2.9 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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