-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aws-arch): pricing manifest caching and automation
To support deterministic caching of aws-arch genoration of aws pricing, we need to store the manifest locally since. Creating github workflow to support weekly updates along with snapshot updates and build verification - currently requires manually approval.
- Loading branch information
1 parent
79f0bfc
commit ecdc5a7
Showing
8 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: aws-arch-pricing | ||
on: | ||
workflow_dispatch: {} | ||
schedule: | ||
- cron: 0 0 * * 1 | ||
jobs: | ||
update: | ||
name: Update Pricing | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
outputs: | ||
patch_created: ${{ steps.create_patch.outputs.patch_created }} | ||
env: | ||
CI: "false" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: mainline | ||
- name: Install dependencies | ||
run: yarn install --check-files --frozen-lockfile | ||
- name: Fetch Pricing Manifest | ||
working-directory: packages/aws-arch | ||
run: npx projen fetch-pricing-manifest | ||
- name: Build | ||
working-directory: packages/aws-arch | ||
run: npx nx run build | ||
- id: create_patch | ||
name: Find mutations | ||
run: |- | ||
git add . | ||
git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=patch_created::true" | ||
- if: steps.create_patch.outputs.patch_created | ||
name: Upload patch | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: .repo.patch | ||
path: .repo.patch | ||
pr: | ||
name: Create Pull Request | ||
needs: update | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
if: ${{ needs.upgrade.outputs.patch_created }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | ||
ref: mainline | ||
- name: Download patch | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: .repo.patch | ||
path: ${{ runner.temp }} | ||
- name: Apply patch | ||
run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' | ||
- name: Set git identity | ||
run: |- | ||
git config user.name "github-actions" | ||
git config user.email "github-actions@github.com" | ||
- name: Create Pull Request | ||
id: create-pr | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | ||
commit-message: |- | ||
chore(aws-arch): update pricing manifest | ||
Update aws pricing manifest and snapshots for aws-arch package. See details in [workflow run]. | ||
[Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
branch: github-actions/aws-arch-pricing | ||
title: "chore(aws-arch): update pricing manifest" | ||
body: |- | ||
Update aws pricing manifest and snapshots for aws-arch package. See details in [workflow run]. | ||
[Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
author: github-actions <github-actions@github.com> | ||
committer: github-actions <github-actions@github.com> | ||
signoff: false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env ts-node | ||
/********************************************************************************************************************* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************************************************** */ | ||
import * as path from 'path'; | ||
import * as util from 'util'; | ||
import * as stream from 'stream'; | ||
import * as fs from 'fs-extra'; | ||
import fetch from 'node-fetch'; | ||
|
||
const URL = 'https://d1qsjq9pzbk1k6.cloudfront.net/manifest/en_US.json'; | ||
|
||
const FILEPATH = path.join(__dirname, '..', 'static', 'aws-pricing-manifest.json'); | ||
|
||
(async () => { | ||
console.info('Fetching pricing manifest...'); | ||
const response = await fetch(URL); | ||
if (!response.ok) { | ||
console.debug(response); | ||
throw new Error(`Failed to download pricing manifest: ${response.statusText} - ${response.statusText}`); | ||
} | ||
await util.promisify(stream.pipeline)(response.body, fs.createWriteStream(FILEPATH)); | ||
console.info('Done - pricing manifest fetched') | ||
})(); |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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