Petzys commited on
Commit
25529f3
·
1 Parent(s): 8e406f2

feat: conditional syncing on test success

Browse files
.github/workflows/hf_sync.yml DELETED
@@ -1,20 +0,0 @@
1
- name: Sync to Hugging Face hub
2
- on:
3
- push:
4
- branches: [main]
5
-
6
- # to run this workflow manually from the Actions tab
7
- workflow_dispatch:
8
-
9
- jobs:
10
- sync-to-hub:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v3
14
- with:
15
- fetch-depth: 0
16
- lfs: true
17
- - name: Push to hub
18
- env:
19
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
- run: git push https://bapaurana:[email protected]/spaces/bapaurana/xkcd_finder main
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/{test.yml → test_sync.yml} RENAMED
@@ -1,4 +1,5 @@
1
- name: Test Code
 
2
  on:
3
  push:
4
  branches:
@@ -15,32 +16,49 @@ jobs:
15
  with:
16
  fetch-depth: 0
17
  lfs: true
 
18
  - uses: actions/setup-python@v5
19
  with:
20
  python-version: 3.11.5
 
21
  - name: Install dependencies
22
  run: pip install pytest
 
23
  - name: Test code
24
  id: test
25
  continue-on-error: true
26
  run: pytest
27
 
28
- - name: Send test results to Discord
29
  if: steps.test.outcome != 'success'
30
  env:
31
  DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
32
  run: |
33
  curl -X POST -H "Content-Type: application/json" \
34
  -d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. But the test has failed :sad:\"}" \
35
- $DISCORD_WEBHOOK_URL
36
  exit 1
37
 
38
- - name: Send test results to Discord
39
  if: steps.test.outcome == 'success'
40
  env:
41
  DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
42
  run: |
43
  curl -X POST -H "Content-Type: application/json" \
44
  -d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. Tests have passed! :smile:\"}" \
45
- $DISCORD_WEBHOOK_URL
46
  exit 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Test & Sync
2
+
3
  on:
4
  push:
5
  branches:
 
16
  with:
17
  fetch-depth: 0
18
  lfs: true
19
+
20
  - uses: actions/setup-python@v5
21
  with:
22
  python-version: 3.11.5
23
+
24
  - name: Install dependencies
25
  run: pip install pytest
26
+
27
  - name: Test code
28
  id: test
29
  continue-on-error: true
30
  run: pytest
31
 
32
+ - name: Send test results to Discord (failed)
33
  if: steps.test.outcome != 'success'
34
  env:
35
  DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
36
  run: |
37
  curl -X POST -H "Content-Type: application/json" \
38
  -d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. But the test has failed :sad:\"}" \
39
+ $DISCORD_WEBHOOK_URL
40
  exit 1
41
 
42
+ - name: Send test results to Discord (success)
43
  if: steps.test.outcome == 'success'
44
  env:
45
  DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
46
  run: |
47
  curl -X POST -H "Content-Type: application/json" \
48
  -d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. Tests have passed! :smile:\"}" \
49
+ $DISCORD_WEBHOOK_URL
50
  exit 0
51
+
52
+ deploy:
53
+ needs: test-code
54
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v3
58
+ with:
59
+ fetch-depth: 0
60
+ lfs: true
61
+ - name: Push to hub
62
+ env:
63
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
64
+ run: git push https://bapaurana:[email protected]/spaces/bapaurana/xkcd_finder main