create-preview-workflow 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -15,6 +15,8 @@ const prompts = require("prompts");
|
|
15
15
|
name: Sync Directory
|
16
16
|
on:
|
17
17
|
push:
|
18
|
+
paths:
|
19
|
+
- '${response.sourcePath}/**'
|
18
20
|
jobs:
|
19
21
|
sync:
|
20
22
|
runs-on: ubuntu-latest
|
@@ -26,12 +28,16 @@ jobs:
|
|
26
28
|
REPO="\${{ github.event.repository.name }}"
|
27
29
|
DIR="\${USER}@\${REPO}"
|
28
30
|
COMMIT_MSG="\$(git log -1 --pretty=format:'%s')"
|
31
|
+
COMMIT_SHA="\$(git log -1 --pretty=format:'%H')"
|
29
32
|
PUSH_TIME="\$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
|
33
|
+
GITHUB_URL="https://github.com/\${USER}/\${REPO}/commit/\${COMMIT_SHA}"
|
30
34
|
echo "USER=\$USER" >> \$GITHUB_ENV
|
31
35
|
echo "REPO=\$REPO" >> \$GITHUB_ENV
|
32
36
|
echo "DIR=\$DIR" >> \$GITHUB_ENV
|
33
37
|
echo "COMMIT_MSG=\$COMMIT_MSG" >> \$GITHUB_ENV
|
38
|
+
echo "COMMIT_SHA=\$COMMIT_SHA" >> \$GITHUB_ENV
|
34
39
|
echo "PUSH_TIME=\$PUSH_TIME" >> \$GITHUB_ENV
|
40
|
+
echo "GITHUB_URL=\$GITHUB_URL" >> \$GITHUB_ENV
|
35
41
|
- name: Clone target repo
|
36
42
|
run: |
|
37
43
|
git clone https://\${{ secrets.GH_SYNC_TOKEN }}@github.com/ssm123ssm/preview.git
|
@@ -43,7 +49,9 @@ jobs:
|
|
43
49
|
cd preview/public/protected/\$DIR
|
44
50
|
echo "Last sync: \$PUSH_TIME" > .sync_log
|
45
51
|
echo "Last commit: \$COMMIT_MSG" >> .sync_log
|
52
|
+
echo "Commit SHA: \$COMMIT_SHA" >> .sync_log
|
46
53
|
echo "Source: \$USER/\$REPO" >> .sync_log
|
54
|
+
echo "View diff: \$GITHUB_URL" >> .sync_log
|
47
55
|
- name: Commit and push changes
|
48
56
|
run: |
|
49
57
|
cd preview
|
@@ -61,6 +69,6 @@ jobs:
|
|
61
69
|
fs.mkdirSync(destDir, { recursive: true });
|
62
70
|
fs.writeFileSync(path.join(destDir, "sync.yml"), workflow);
|
63
71
|
console.log(
|
64
|
-
"GitHub Actions workflow for Preview created at .github/workflows/sync.yml. Make sure to add the GH_SYNC_TOKEN secret in your repository settings."
|
72
|
+
"✅ GitHub Actions workflow for Preview created at .github/workflows/sync.yml. Make sure to add the GH_SYNC_TOKEN secret in your repository settings."
|
65
73
|
);
|
66
74
|
})();
|