Skip to content

Create graphviz.yml #505

Create graphviz.yml

Create graphviz.yml #505

name: auto-release-when-pr-is-merged
on:
pull_request:
types:
- closed
branches:
- main
jobs:
draft-release:
if: ${{ github.event.pull_request.merged == true && ! contains( github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: prepare release tag
run: echo "release_tag=v$(date '+%Y%m%d_%H%M%S')" >> "$GITHUB_ENV"
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `PR has been merged. we're processing it! (${new Date()})`
})
- name: Create Release
id: release
uses: actions/create-release@v1 # not maintained
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.release_tag }}
release_name: ${{ env.release_tag }}
body: |
This release is automatically created by [GitHub Actions auto-release-when-pr-is-merged.yml](https://github.com/nakamasato/github-actions-practice/blob/master/.github/workflows/auto-release-when-pr-is-merged.yml).
Triggered PR: [${{ github.event.number }}:${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) created by ${{ github.actor }}
draft: true
prerelease: false
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Draft release ([${{ steps.release.outputs.id }}](${{ steps.release.outputs.html_url }})) has been created. (${new Date()})`
})
release:
if: ${{ github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest
env:
PUBLISH_RELEASE_SCRIPT: ./.publish-release.sh
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
ref: main
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `PR has been merged. we're publishing a new release! (${new Date()})`
})
- name: git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sh "$PUBLISH_RELEASE_SCRIPT"
release_tag=$(gh release view --json tagName | jq -r .tagName)
release_url=$(gh release view --json url | jq -r .url)
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
echo "release_url=$release_url" >> "$GITHUB_OUTPUT"
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `New release [${{ steps.release.outputs.release_tag }}](${{ steps.release.outputs.release_url }}) has been published! (${new Date()})`
})