Skip to content

Commit 90616a7

Browse files
committed
Update workflow
1 parent bddd5ef commit 90616a7

3 files changed

Lines changed: 78 additions & 4 deletions

File tree

.github/scripts/copy-content-engine-files.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*
55
* Usage:
66
* npm run copy:content-engine
7+
*
8+
* Optional:
9+
* CONTENT_ENGINE_DESTINATION_ROOT=/path/to/cse-content-engine/content/learning-pathways/copilot-cli-for-beginners npm run copy:content-engine
710
*/
811

912
const {
@@ -12,13 +15,18 @@ const {
1215
mkdirSync,
1316
readdirSync,
1417
readFileSync,
18+
rmSync,
1519
statSync,
1620
writeFileSync,
1721
} = require('fs');
1822
const { dirname, join, relative, resolve } = require('path');
1923

2024
const sourceRoot = process.cwd();
21-
const destinationRoot = '/Users/danwahlin/Desktop/projects/cse-content-engine/content/learning-pathways/copilot-cli-for-beginners';
25+
const defaultDestinationRoot = resolve(
26+
sourceRoot,
27+
'../cse-content-engine/content/learning-pathways/copilot-cli-for-beginners',
28+
);
29+
const destinationRoot = resolve(process.env.CONTENT_ENGINE_DESTINATION_ROOT || defaultDestinationRoot);
2230
const destinationParent = dirname(destinationRoot);
2331
const contentEngineSchema = {
2432
$schema: 'http://json-schema.org/draft-07/schema#',
@@ -95,6 +103,11 @@ function ensureSafeDestination() {
95103
}
96104
}
97105

106+
function resetDestination() {
107+
rmSync(destinationRoot, { recursive: true, force: true });
108+
log(`Cleared ${destinationRoot}`);
109+
}
110+
98111
function copyFile(sourcePath, destinationPath) {
99112
mkdirSync(dirname(destinationPath), { recursive: true });
100113

@@ -333,6 +346,7 @@ function validateMarkdownFrontmatter() {
333346
}
334347

335348
ensureSafeDestination();
349+
resetDestination();
336350
copyCourseContent();
337351
validateMarkdownFrontmatter();
338352
validateMarkdownImagePaths();

.github/workflows/co-op-translator.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343

4444
steps:
4545
- name: Checkout repository
46-
uses: actions/checkout@v4
46+
uses: actions/checkout@v7
4747
with:
4848
fetch-depth: 0
4949

5050
- name: Set up Python
51-
uses: actions/setup-python@v5
51+
uses: actions/setup-python@v6
5252
with:
5353
python-version: "3.12"
5454

@@ -105,7 +105,7 @@ jobs:
105105
106106
- name: Upload Co-op Translator logs
107107
if: always()
108-
uses: actions/upload-artifact@v4
108+
uses: actions/upload-artifact@v7
109109
with:
110110
name: co-op-translator-logs
111111
path: logs/
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Sync content-engine copy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: sync-content-engine-copy
14+
cancel-in-progress: true
15+
16+
jobs:
17+
sync-content:
18+
name: Copy content and open content-engine PR
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
22+
steps:
23+
- name: Checkout course repository
24+
uses: actions/checkout@v4
25+
with:
26+
path: copilot-cli-for-beginners
27+
28+
- name: Checkout content-engine repository
29+
uses: actions/checkout@v4
30+
with:
31+
repository: github/cse-content-engine
32+
token: ${{ secrets.GH_AW_GITHUB_TOKEN }}
33+
path: cse-content-engine
34+
35+
- name: Set up Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: "20"
39+
40+
- name: Copy course content into content-engine
41+
working-directory: copilot-cli-for-beginners
42+
env:
43+
CONTENT_ENGINE_DESTINATION_ROOT: ${{ github.workspace }}/cse-content-engine/content/learning-pathways/copilot-cli-for-beginners
44+
run: npm run copy:content-engine
45+
46+
- name: Create content-engine pull request
47+
uses: peter-evans/create-pull-request@v7
48+
with:
49+
path: cse-content-engine
50+
token: ${{ secrets.GH_AW_GITHUB_TOKEN }}
51+
commit-message: "Update Copilot CLI for Beginners content"
52+
title: "Update Copilot CLI for Beginners content"
53+
body: |
54+
This automated PR syncs the latest `github/copilot-cli-for-beginners`
55+
content into the content-engine learning pathway.
56+
57+
Source commit: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
58+
branch: update/copilot-cli-for-beginners-content
59+
base: main
60+
delete-branch: true

0 commit comments

Comments
 (0)