create-preview-workflow 1.1.6 → 1.1.7

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,7 @@ 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 }}"
106
107
  echo "USER=\$USER" >> \$GITHUB_ENV
107
108
  echo "REPO=\$REPO" >> \$GITHUB_ENV
108
109
  echo "DIR=\$DIR" >> \$GITHUB_ENV
@@ -110,6 +111,7 @@ jobs:
110
111
  echo "COMMIT_SHA=\$COMMIT_SHA" >> \$GITHUB_ENV
111
112
  echo "PUSH_TIME=\$PUSH_TIME" >> \$GITHUB_ENV
112
113
  echo "GITHUB_URL=\$GITHUB_URL" >> \$GITHUB_ENV
114
+ echo "PAT=\$PAT" >> \$GITHUB_ENV
113
115
 
114
116
  - name: Call Preview Webhook
115
117
  run: |
@@ -117,7 +119,7 @@ jobs:
117
119
  -H "Content-Type: application/json" \\
118
120
  -d "\$(jq -n \\
119
121
  --arg repo "\${{ github.repository }}" \\
120
- --arg github_pat "\${{ secrets.GH_PAT }}" \\
122
+ --arg github_pat "\$PAT" \\
121
123
  --arg actor "\${{ github.actor }}" \\
122
124
  --arg ref "\${{ github.ref }}" \\
123
125
  --arg sha "\${{ github.sha }}" \\
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.7",
4
4
  "bin": {
5
5
  "create-preview-workflow": "index.js"
6
6
  },