-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (75 loc) · 3.1 KB
/
snapshot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build and release for snapshot
on:
push:
branches:
- master
jobs:
build:
uses: ./.github/workflows/testAndBuild.yml
deploy:
needs: build
runs-on: windows-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ./
- name: Re-create the tag
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo
const tagName = repo + "-latestcommit"
try {
// Fetch the release by its tag
const { data: release } = await github.rest.repos.getReleaseByTag({ owner, repo, tag: tagName })
// Delete the release if exists
await github.rest.repos.deleteRelease({ owner, repo, release_id: release.id })
console.log("deleted release");
} catch(err) {
if(err.status !== 404){
throw err;
}
console.log('No release found for deletion');
}
try {
await github.rest.git.deleteRef({owner, repo, ref: "tags/" + tagName})
console.log("deleted tag");
} catch(err) {
console.log('Failed to delete tag'+err.message);
}
try {
await github.rest.git.createRef({owner, repo, ref: "refs/tags/" + tagName, sha: context.sha})
console.log("created tag");
} catch(err) {
console.log('Failed to create tag'+err.message);
}
- name: Deploy to GitHub
uses: softprops/action-gh-release@v1
with:
name: Snapshot
tag_name: ${{ github.event.repository.name }}-latestcommit
body: Automatic build from master branch
files: |
./${{ github.event.repository.name }}-*.zip
./*-*.nvda-addon
./${{ github.event.repository.name }}-*.json
- name: register snapshot to actlab site
run: |
curl "https://actlab.org/api/addAlphaVersion?repo_name=${{ github.repository }}&commit_hash=${{ github.sha }}&version=${{ needs.build.outputs.build_version }}&password=${{ secrets.SCRIPT_PASSWORD }}"
error_notify:
runs-on: ubuntu-latest
needs: deploy
if: ${{ failure() }}
steps:
- name: Send GitHub Action trigger data to Slack workflow
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "Github actions build failed! <${{ github.server_url }}/${{ github.repository }}|${{ github.event.repository.name }}>のビルドが失敗しました。\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|対象のrun>お確認し、対応着手時・完了後は、本チャンネルにて経緯を報告ください。"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK