forked from omni/tokenbridge
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
atif
committed
Sep 26, 2024
1 parent
b032ba8
commit bed2bb8
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Create Github Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
# Permission can be added at job level or workflow level | ||
permissions: | ||
contents: write # This is required for actions/checkout and create release | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
name: Github Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Create Github Release | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ github.token }} | ||
script: | | ||
if (!${{ toJson(github.ref_name) }}) { | ||
core.setFailed("RELEASE_TAG is not defined.") | ||
return; | ||
} | ||
try { | ||
const response = await github.rest.repos.createRelease({ | ||
name: ${{ toJson(github.ref_name) }}, | ||
tag_name: ${{ toJson(github.ref_name) }}, | ||
draft: false, | ||
generate_release_notes: true, | ||
owner: context.repo.owner, | ||
prerelease: false, | ||
repo: context.repo.repo, | ||
}); | ||
core.exportVariable('RELEASE_ID', response.data.id); | ||
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Slack Notify Release | ||
on: | ||
workflow_call: | ||
secrets: | ||
RELEASES_SLACK_WEBHOOK_URL: | ||
required: true | ||
inputs: | ||
environment: | ||
type: string | ||
required: true | ||
message: | ||
type: string | ||
required: true | ||
service: | ||
type: string | ||
required: true | ||
success: | ||
type: boolean | ||
required: true | ||
|
||
jobs: | ||
notify: | ||
name: Notify ${{ inputs.service }} release in ${{ inputs.environment }} | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- name: Extract branch name | ||
shell: bash | ||
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | ||
id: extract_branch | ||
|
||
- name: Extract commit | ||
id: commit | ||
uses: prompt/actions-commit-hash@v2 | ||
|
||
- name: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')" | ||
|
||
- id: slack | ||
uses: slackapi/slack-github-action@v1.24.0 | ||
with: | ||
payload: "{\"username\":\"Releases\",\"icon_url\":\"https://avatars3.githubusercontent.com/u/134083290\",\"text\":\"${{ inputs.message }} - ${{ github.event.head_commit.message }}\",\"attachments\":[{\"text\":\"\",\"color\":\"${{ inputs.success == true && '#36a64f' || '#FF3131' }}\",\"author_name\":\"${{ inputs.service }}\",\"title\":\"\",\"fields\":[{\"title\":\"Environment\",\"short\":true,\"value\":\"`${{ inputs.environment }}`\"},{\"title\":\"Branch\",\"short\":true,\"value\":\"${{ steps.extract_branch.outputs.branch }}\"},{\"title\":\"Commit\",\"short\":true,\"value\":\"${{ steps.commit.outputs.short }}\"},{\"title\":\"Status\",\"short\":true,\"value\":\"${{ inputs.success == true && '🟢 SUCCEEDED' || '🔴 FAILED' }}\"},{\"title\":\"Time\",\"short\":true,\"value\":\"${{ steps.date.outputs.date }}\"}]}]}" | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.RELEASES_SLACK_WEBHOOK_URL }} | ||
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK" |