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