-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Sync Presenters from People Profiles (#2916)
* Save progress * Pull all data from SSW.People.Profiles * Update TinaLock * Implement get-people-profiles * Update Action, add temp files to gitignore * Remove images * Update tinalock * Update action * up * Update * Update to keep existing values * Update relative path * Replace Partner images * Update Action. Remove unnecessary files * Update to fetch data from SSW People * Update to save files * Update Presenter Tsx with Skills string * enable auto-merge * Update * Fix action * Fetch People Profiles * Revert "Merge pull request #5 from tkapa/sync/people-profiles" This reverts commit 0a884dd, reversing changes made to f47c21d. * Use proper casing for files * Fetch People Profiles * Revert "Merge pull request #6 from tkapa/sync/people-profiles" This reverts commit 71cc74c, reversing changes made to 30eeb2f. * Use capitalised for img * Fetch People Profiles * Revert "Merge pull request #7 from tkapa/sync/people-profiles" This reverts commit 8d2569c, reversing changes made to ebdfc2f. * Run a build on the new files * Comment out auto-merge for now * Run a build before merge * Add GitHub App * Enable Auto-Merge on PR * Fetch People Profiles (#11) Co-authored-by: tkapa <[email protected]> * Revert "Fetch People Profiles (#11)" This reverts commit ab447ac. * Add Auto flag to enable step * Only once a week * Mitigate Errors * Update to use lts/* * Reference .nvmrc --------- Co-authored-by: tkapa <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ssw-website-app[bot] <177506588+ssw-website-app[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7c41918
commit a7b8111
Showing
5 changed files
with
152 additions
and
2 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,75 @@ | ||
name: Weekly - Fetch SSW People Profiles | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 * * TUE" | ||
|
||
env: | ||
TEMPORARY_FOLDER: temp-profiles | ||
SSW_PEOPLE_BASE_URL: https://ssw.com.au/people | ||
|
||
jobs: | ||
fetch-and-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Checkout People Profiles | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: "SSWConsulting/SSW.People.Profiles" | ||
path: ${{ env.TEMPORARY_FOLDER}} | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ${{ env.GITHUB_WORKSPACE }}/.nvmrc | ||
|
||
- run: corepack enable pnpm | ||
- run: pnpm add -w gray-matter | ||
|
||
- name: Fetch SSW.People.Profiles | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/get-people-profiles.js`); | ||
await script({ | ||
github, | ||
context, | ||
peopleBaseUrl: `${process.env.SSW_PEOPLE_BASE_URL}`, | ||
peopleDirectory: `${process.env.GITHUB_WORKSPACE}/${ process.env.TEMPORARY_FOLDER }`, | ||
websiteContentPath: `${process.env.GITHUB_WORKSPACE}/content`, | ||
websitePublicPath: `${process.env.GITHUB_WORKSPACE}/public`, | ||
presentersPath: `presenters`, | ||
peopleImagePath: `images/people` | ||
}); | ||
- uses: actions/create-github-app-token@v1 | ||
id: get-app-token | ||
with: | ||
app-id: ${{ vars.GH_APP_ID }} | ||
private-key: ${{ secrets.GH_APP_KEY }} | ||
|
||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ steps.get-app-token.outputs.token }} | ||
commit-message: "Fetch People Profiles" | ||
title: "Auto - Fetch People Profiles" | ||
body: > | ||
Created by GitHub Action. | ||
- Syncs data from [SSW.People.Profiles](https://github.com/SSWConsulting/SSW.People.Profiles) | ||
branch: "sync/people-profiles" | ||
# We only expect changes to these folders | ||
add-paths: | | ||
content/* | ||
public/* | ||
- name: Enable Auto-Merge | ||
if: ${{ steps.cpr.outputs.pull-request-number }} | ||
run: gh pr merge -s --auto ${{ steps.cpr.outputs.pull-request-number }} | ||
env: | ||
GH_TOKEN: ${{ steps.get-app-token.outputs.token }} |
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,63 @@ | ||
const matter = require('gray-matter'); | ||
const fs = require('fs'); | ||
|
||
const GetPeopleProfiles = async ( { | ||
github, | ||
context, | ||
peopleBaseUrl, | ||
peopleDirectory, | ||
websiteContentPath, | ||
websitePublicPath, | ||
presentersPath, | ||
peopleImagePath | ||
} ) => { | ||
const presentersDirectory = `${websiteContentPath}/${presentersPath}`; | ||
const peopleImageDirectory = `${websitePublicPath}/${peopleImagePath}`; | ||
|
||
fs.mkdirSync(presentersDirectory, { recursive: true }); | ||
fs.mkdirSync(peopleImageDirectory, { recursive: true }); | ||
|
||
try { | ||
const people = await fetch(`${peopleBaseUrl}/people.json`); | ||
const peopleList = await people.json(); | ||
|
||
peopleList.forEach(async person => { | ||
console.log(`Processing ${person}`); | ||
|
||
const contentPresenterPath = `${presentersDirectory}/${person}.mdx`; | ||
const peopleMd = await fetch(`${peopleBaseUrl}/${person}/profile.md`); | ||
const peopleMdStr = await peopleMd.text(); | ||
|
||
var presenterJson = {}; | ||
const peopleMatter = matter(peopleMdStr); | ||
|
||
if (fs.existsSync(contentPresenterPath)) { | ||
const existingPresenterFile = matter.read(contentPresenterPath); | ||
presenterJson = existingPresenterFile.data; | ||
} | ||
|
||
presenterJson = { | ||
...presenterJson, | ||
...peopleMatter.data, | ||
}; | ||
|
||
const personName = presenterJson.presenter?.name?.split(' ')?.join('-') ?? 'not-found'; | ||
const profileImageRelativePath = `${peopleImagePath}/${personName}.jpg`; | ||
const peopleProfileImagePath = `${peopleDirectory}/${personName}/Images/${personName}-Profile.jpg`; | ||
|
||
presenterJson.profileImg = presenterJson.profileImg ?? ``; | ||
|
||
if (fs.existsSync(peopleProfileImagePath)) { | ||
fs.copyFileSync(peopleProfileImagePath, `${websitePublicPath}/${profileImageRelativePath}`); | ||
presenterJson.profileImg = `/${profileImageRelativePath}`; | ||
} | ||
|
||
console.log(`Writing ${contentPresenterPath}`); | ||
fs.writeFileSync(contentPresenterPath, matter.stringify('', presenterJson)); | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
module.exports = GetPeopleProfiles; |
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
Large diffs are not rendered by default.
Oops, something went wrong.