create-preview-workflow 1.1.6 → 1.1.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.
@@ -1,55 +1,38 @@
1
1
  # .github/workflows/sync.yml
2
- name: Sync Directory
2
+ name: Delete Directory
3
3
 
4
4
  on:
5
5
  push:
6
6
  paths:
7
- - "test/**"
8
7
  - ".github/workflows/sync.yml"
9
8
 
10
9
  jobs:
11
- sync:
10
+ delete:
12
11
  runs-on: ubuntu-latest
13
12
  steps:
14
13
  - uses: actions/checkout@v3
15
- with:
16
- fetch-depth: 2
17
14
 
18
15
  - name: Set variables
19
16
  run: |
20
17
  USER="${{ github.actor }}"
21
18
  REPO="${{ github.event.repository.name }}"
22
19
  DIR="${USER}@${REPO}"
23
- COMMIT_MSG="$(git log -1 --pretty=format:'%s')"
24
- COMMIT_SHA="$(git log -1 --pretty=format:'%H')"
25
- PUSH_TIME="$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
26
- GITHUB_URL="https://github.com/${USER}/${REPO}/commit/${COMMIT_SHA}"
27
20
  echo "USER=$USER" >> $GITHUB_ENV
28
21
  echo "REPO=$REPO" >> $GITHUB_ENV
29
22
  echo "DIR=$DIR" >> $GITHUB_ENV
30
- echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_ENV
31
- echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
32
- echo "PUSH_TIME=$PUSH_TIME" >> $GITHUB_ENV
33
- echo "GITHUB_URL=$GITHUB_URL" >> $GITHUB_ENV
34
23
 
35
- - name: Clone target repo and sync content
24
+ - name: Call Delete Webhook
36
25
  run: |
37
- git clone https://${{ secrets.GH_SYNC_TOKEN }}@github.com/ssm123ssm/preview.git
38
- rm -rf preview/public/protected/$DIR
39
- mkdir -p preview/public/protected/$DIR
40
- cp -r test/. preview/public/protected/$DIR/
41
- echo "Last sync: $PUSH_TIME" > preview/public/protected/$DIR/.sync_log
42
- echo "Last commit: $COMMIT_MSG" >> preview/public/protected/$DIR/.sync_log
43
- echo "Commit SHA: $COMMIT_SHA" >> preview/public/protected/$DIR/.sync_log
44
- echo "Source: $USER/$REPO" >> preview/public/protected/$DIR/.sync_log
45
- echo "View diff: $GITHUB_URL" >> preview/public/protected/$DIR/.sync_log
46
- cd preview
47
- git config user.name "GitHub Actions"
48
- git config user.email "actions@github.com"
49
- git add .
50
- if ! git diff --cached --quiet; then
51
- git commit -m "Sync content from source repo"
52
- git push
53
- else
54
- echo "No changes to commit"
55
- fi
26
+ curl -X POST http://preview.neurasense.io:30010/delete \
27
+ -H "Content-Type: application/json" \
28
+ -d "$(jq -n \
29
+ --arg repo "${{ github.repository }}" \
30
+ --arg actor "${{ github.actor }}" \
31
+ --arg user "$USER" \
32
+ --arg repo_name "$REPO" \
33
+ --arg dir "$DIR" \
34
+ '{
35
+ repository: $repo,
36
+ actor: $actor,
37
+ directory: $dir
38
+ }')"
package/index.js CHANGED
@@ -103,6 +103,8 @@ jobs:
103
103
  COMMIT_SHA="\$(git log -1 --pretty=format:'%H')"
104
104
  PUSH_TIME="\$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
105
105
  GITHUB_URL="https://github.com/\${USER}/\${REPO}/commit/\${COMMIT_SHA}"
106
+ PAT="\${{ secrets.GH_PAT }}"
107
+ SOURCE_PATH="${response.sourcePath}"
106
108
  echo "USER=\$USER" >> \$GITHUB_ENV
107
109
  echo "REPO=\$REPO" >> \$GITHUB_ENV
108
110
  echo "DIR=\$DIR" >> \$GITHUB_ENV
@@ -110,6 +112,8 @@ jobs:
110
112
  echo "COMMIT_SHA=\$COMMIT_SHA" >> \$GITHUB_ENV
111
113
  echo "PUSH_TIME=\$PUSH_TIME" >> \$GITHUB_ENV
112
114
  echo "GITHUB_URL=\$GITHUB_URL" >> \$GITHUB_ENV
115
+ echo "PAT=\$PAT" >> \$GITHUB_ENV
116
+ echo "SOURCE_PATH=\$SOURCE_PATH" >> \$GITHUB_ENV
113
117
 
114
118
  - name: Call Preview Webhook
115
119
  run: |
@@ -117,7 +121,7 @@ jobs:
117
121
  -H "Content-Type: application/json" \\
118
122
  -d "\$(jq -n \\
119
123
  --arg repo "\${{ github.repository }}" \\
120
- --arg github_pat "\${{ secrets.GH_PAT }}" \\
124
+ --arg github_pat "\$PAT" \\
121
125
  --arg actor "\${{ github.actor }}" \\
122
126
  --arg ref "\${{ github.ref }}" \\
123
127
  --arg sha "\${{ github.sha }}" \\
@@ -129,7 +133,7 @@ jobs:
129
133
  --arg commit_sha "\$COMMIT_SHA" \\
130
134
  --arg push_time "\$PUSH_TIME" \\
131
135
  --arg github_url "\$GITHUB_URL" \\
132
- --arg source_path "${response.sourcePath}" \\
136
+ --arg source_path "\$SOURCE_PATH" \\
133
137
  '{
134
138
  repository: \$repo,
135
139
  actor: \$actor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-preview-workflow",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "bin": {
5
5
  "create-preview-workflow": "index.js"
6
6
  },