-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add workflows to post news #125
Open
andresriveratoro
wants to merge
18
commits into
main
Choose a base branch
from
api-22679-news
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
428df46
Add workflows to post news
andresriveratoro b539b4a
Merge branch 'main' into api-22679-news
andresriveratoro 9d4553b
Update branch name
andresriveratoro 907e408
Revert branch name change
andresriveratoro c08b7c3
Use date from content
andresriveratoro 9728813
Merge branch 'main' into api-22679-news
andresriveratoro d8b0def
Add path to workflow
andresriveratoro 053c228
Update comment url
andresriveratoro 054b872
Update text manipulation for category
andresriveratoro 94ff512
Limit workflow to main branch
andresriveratoro df7b168
Merge branch 'main' into api-22679-news
andresriveratoro 375c913
Fix path
andresriveratoro 4a5244b
Exit workflow if files are not found
andresriveratoro d6c3319
Update workflows
andresriveratoro 92ca075
Remove step
andresriveratoro 488d68b
Merge branch 'main' into api-22679-news
andresriveratoro 099544b
Merge branch 'main' of github.com:department-of-veterans-affairs/deve…
andresriveratoro 13b3efc
Merge branch 'main' into api-22679-news
andresriveratoro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,219 @@ | ||
name: Post news to Lighthouse Platform Backend (LPB) | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- closed | ||
branches: [main] | ||
paths: | ||
- "content/website/**" | ||
|
||
jobs: | ||
gather_content: | ||
name: Gather the changed content | ||
runs-on: ubuntu-latest | ||
outputs: | ||
rename_warning: ${{ steps.get_target_environment.outputs.rename_warning }} | ||
target_environment: ${{ steps.get_target_environment.outputs.target_environment }} | ||
steps: | ||
- id: get_target_environment | ||
name: Determine Target Environment | ||
run: | | ||
TARGET_ENVIRONMENT="development" | ||
if [ "${{ github.event.pull_request.merged }}" == "true" ]; then | ||
TARGET_ENVIRONMENT="production" | ||
fi | ||
echo $TARGET_ENVIRONMENT | ||
echo "target_environment=$TARGET_ENVIRONMENT" >> $GITHUB_OUTPUT | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- id: pr_files | ||
uses: Ana06/[email protected] | ||
with: | ||
filter: "content/website/**" | ||
- id: upload_content | ||
name: Find files and send them | ||
continue-on-error: true | ||
run: | | ||
# If it's a PR change from a space delimited list to one file per line | ||
if [ "${{ steps.pr_files.outputs.added_modified_renamed }}" != "" ]; then | ||
touch changed-files.txt | ||
for f in `echo "${{ steps.pr_files.outputs.added_modified_renamed }}"`; do | ||
echo $f >> changed-files.txt | ||
done | ||
fi | ||
if [ "${{ steps.pr_files.outputs.renamed }}" != "" ]; then | ||
echo "rename_warning=TRUE" >> $GITHUB_OUTPUT | ||
fi | ||
echo "Expected files changes:" | ||
cat changed-files.txt | ||
- name: Save changed files list | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: changed-files | ||
path: changed-files.txt | ||
send_content_to_development: | ||
name: Send content to development LPB | ||
needs: [gather_content] | ||
environment: | ||
name: development | ||
url: https://dev-developer.va.gov | ||
runs-on: ubuntu-latest | ||
if: needs.gather_content.outputs.target_environment == 'development' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: NPM install | ||
run: npm ci | ||
- id: get_bearer_token | ||
name: Get Bearer Token | ||
env: | ||
LPB_HOST: "dev-api.va.gov" | ||
LPB_CLIENT_ID: ${{ secrets.LPB_CLIENT_ID }} | ||
LPB_RSA_TOKEN: ${{ secrets.LPB_RSA_SECRET }} | ||
OKTA_TOKEN_AUD: "https://deptva-eval.okta.com/oauth2/ausg95zxf6dFPccy02p7/v1/token" | ||
run: echo "$LPB_RSA_TOKEN" > ./rsa.pem; | ||
ls -la; | ||
wc -l ./rsa.pem; | ||
node ./get-bearer-token.js $LPB_CLIENT_ID ./rsa.pem $LPB_HOST $OKTA_TOKEN_AUD; | ||
BEARER_TOKEN=`cat ./bearer.token`; | ||
echo "bearer_token=$BEARER_TOKEN" >> $GITHUB_ENV; | ||
- name: Get file list | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: changed-files | ||
- name: Send content to development | ||
env: | ||
LPB_HOST: "dev-api.va.gov" | ||
run: | ||
for n in `cat changed-files/changed-files.txt | grep 'content/website/news/articles/\|content/website/news/digital-media/'`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
SOURCE_STRING=`cat $n | 's/^.*source:\s*//'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"source\":\"$SOURCE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
for n in `cat changed-files/changed-files.txt | grep content/website/news/releases`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
- name: Comment on PR | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'These changes have been pushed to [dev](https://dev-developer.va.gov/about/news).' | ||
}) | ||
- name: Previously Merged Warning Comment on PR | ||
if: needs.gather_content.outputs.rename_warning == 'TRUE' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'If this release note was merged to the `main` branch on another PR, you will need to reach out to [Team Okapi](https://lighthouseva.slack.com/archives/C01931CFMTQ) to remove the copy that remains on the previous date.' | ||
}) | ||
send_content_to_production: | ||
name: Send content to production LPB | ||
needs: [gather_content] | ||
environment: | ||
name: production | ||
url: https://developer.va.gov | ||
runs-on: ubuntu-latest | ||
if: needs.gather_content.outputs.target_environment == 'production' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: NPM install | ||
run: npm ci | ||
- id: get_bearer_token | ||
name: Get Bearer Token | ||
env: | ||
LPB_HOST: "api.va.gov" | ||
LPB_CLIENT_ID: ${{ secrets.LPB_CLIENT_ID }} | ||
LPB_RSA_TOKEN: ${{ secrets.LPB_RSA_SECRET }} | ||
OKTA_TOKEN_AUD: "https://va.okta.com/oauth2/ausdppulkgBFJDZZe297/v1/token" | ||
run: echo "$LPB_RSA_TOKEN" > ./rsa.pem; | ||
ls -la; | ||
wc -l ./rsa.pem; | ||
node ./get-bearer-token.js $LPB_CLIENT_ID ./rsa.pem $LPB_HOST $OKTA_TOKEN_AUD; | ||
BEARER_TOKEN=`cat ./bearer.token`; | ||
echo "bearer_token=$BEARER_TOKEN" >> $GITHUB_ENV; | ||
- name: Get file list | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: changed-files | ||
- name: Send content to production | ||
env: | ||
LPB_HOST: "api.va.gov" | ||
run: | ||
for n in `cat changed-files/changed-files.txt | grep 'content/website/news/articles/\|content/website/news/digital-media/'`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
SOURCE_STRING=`cat $n | 's/^.*source:\s*//'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"source\":\"$SOURCE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
for n in `cat changed-files/changed-files.txt | grep content/website/news/releases`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
- name: Comment on PR | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'These changes have been pushed to [production](https://developer.va.gov/about/news).' | ||
}) |
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,162 @@ | ||
name: Seed all news to Lighthouse Platform Backend (LPB) | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "What environment are you seeding?" | ||
required: true | ||
type: environment | ||
|
||
jobs: | ||
gather_content: | ||
name: Gather all content | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Find files and artifact them | ||
run: | | ||
find ./content/website -type f > seed-files.txt | ||
echo "All files to upload:" | ||
cat seed-files.txt | ||
- name: Save changed files list | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: seed-files | ||
path: seed-files.txt | ||
send_content_to_development: | ||
name: Send content to development Lighthouse Platform Backend (LPB) | ||
needs: [gather_content] | ||
environment: | ||
name: development | ||
url: https://dev-developer.va.gov | ||
runs-on: ubuntu-latest | ||
if: ${{ inputs.environment == 'development' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: NPM install | ||
run: npm ci | ||
- id: get_bearer_token | ||
name: Get Bearer Token | ||
env: | ||
LPB_HOST: "dev-api.va.gov" | ||
LPB_CLIENT_ID: ${{ secrets.LPB_CLIENT_ID }} | ||
LPB_RSA_TOKEN: ${{ secrets.LPB_RSA_SECRET }} | ||
OKTA_TOKEN_AUD: "https://deptva-eval.okta.com/oauth2/ausg95zxf6dFPccy02p7/v1/token" | ||
run: echo "$LPB_RSA_TOKEN" > ./rsa.pem; | ||
ls -la; | ||
wc -l ./rsa.pem; | ||
node ./get-bearer-token.js $LPB_CLIENT_ID ./rsa.pem $LPB_HOST $OKTA_TOKEN_AUD; | ||
BEARER_TOKEN=`cat ./bearer.token`; | ||
echo "bearer_token=$BEARER_TOKEN" >> $GITHUB_ENV; | ||
echo "::set-output name=bearer_token::$BEARER_TOKEN" | ||
- name: Get file list | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: seed-files | ||
- name: Seed content to development | ||
env: | ||
LPB_HOST: "dev-api.va.gov" | ||
BEARER_TOKEN: ${{ steps.get_bearer_token.outputs.bearer_token }} | ||
run: | ||
for n in `cat seed-files/seed-files.txt | grep 'content/website/news/articles/\|content/website/news/digital-media/'`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
SOURCE_STRING=`cat $n | 's/^.*source:\s*//'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"source\":\"$SOURCE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
for n in `cat changed-files/changed-files.txt | grep content/website/news/releases`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
send_content_to_production: | ||
name: Send content to production Lighthouse Platform Backend (LPB) | ||
needs: [gather_content] | ||
environment: | ||
name: production | ||
url: https://developer.va.gov | ||
runs-on: ubuntu-latest | ||
if: ${{ inputs.environment == 'production' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: NPM install | ||
run: npm ci | ||
- id: get_bearer_token | ||
name: Get Bearer Token | ||
env: | ||
LPB_HOST: "api.va.gov" | ||
LPB_CLIENT_ID: ${{ secrets.LPB_CLIENT_ID }} | ||
LPB_RSA_TOKEN: ${{ secrets.LPB_RSA_SECRET }} | ||
OKTA_TOKEN_AUD: "https://va.okta.com/oauth2/ausdppulkgBFJDZZe297/v1/token" | ||
run: echo "$LPB_RSA_TOKEN" > ./rsa.pem; | ||
ls -la; | ||
wc -l ./rsa.pem; | ||
node ./get-bearer-token.js $LPB_CLIENT_ID ./rsa.pem $LPB_HOST $OKTA_TOKEN_AUD; | ||
BEARER_TOKEN=`cat ./bearer.token`; | ||
echo "bearer_token=$BEARER_TOKEN" >> $GITHUB_ENV; | ||
echo "::set-output name=bearer_token::$BEARER_TOKEN" | ||
- name: Get file list | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: seed-files | ||
- name: Seed content to production | ||
env: | ||
LPB_HOST: "api.va.gov" | ||
BEARER_TOKEN: ${{ steps.get_bearer_token.outputs.bearer_token }} | ||
run: | ||
for n in `cat seed-files/seed-files.txt | grep 'content/website/news/articles/\|content/website/news/digital-media/'`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
SOURCE_STRING=`cat $n | 's/^.*source:\s*//'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"source\":\"$SOURCE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; | ||
for n in `cat changed-files/changed-files.txt | grep content/website/news/releases`; do | ||
echo "Posting $n to LPB"; | ||
DATE_STRING=`echo $n | 's/^.*date:\s*//'`; | ||
TITLE_STRING=`cat $n | 's/^.*title:\s*//'`; | ||
TARGET_NEWS_CATEGORY=`echo $n | sed -E 's/.*\/([a-z\-]{1,})\/.*/\1/'`; | ||
URL_STRING=`cat $n | 's/^.*url:\s*//'`; | ||
echo "Target URL https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items"; | ||
curl | ||
--request POST | ||
--header 'Content-Type:application/json' | ||
--header "Authorization:Bearer ${{ env.bearer_token }}" | ||
--data "{\"date\":\"$DATE_STRING\",\"title\":\"$TITLE_STRING\",\"url\":\"$URL_STRING\"}" | ||
https://$LPB_HOST/internal/platform-backend/v0/news/categories/$TARGET_NEWS_CATEGORY/items; | ||
done; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to reference it being news, not release notes. Also the ending of this error talks about the date. Are we doing any deduplication of news posts on the LPB side? Would this error ever hit?