Update README.md #4293
Workflow file for this run
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
name: context | |
on: | |
pull_request: | |
types: | |
- edited | |
- opened | |
- synchronize # default | |
- ready_for_review | |
- labeled | |
- unlabeled | |
- closed | |
workflow_dispatch: | |
push: | |
env: | |
TEST_ENV: ${{ (github.event_name == 'release' && 'prod') || 'dev' }} | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: echo toJson(github) | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: env ${{ env.TEST_ENV }} | |
run: echo "$TEST_ENV" | |
- name: github.event.action | |
env: | |
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
run: | | |
echo "- github.event.action : ${{ github.event.action }}" | |
{ | |
echo "- github.event.action : ${{ github.event.action }}" | |
echo "- github.ref_name : ${{ github.ref_name }}" | |
echo "- github.event.pull_request.head.ref : $PR_HEAD_REF" | |
} >> "$GITHUB_STEP_SUMMARY" | |
- name: branch name | |
env: | |
BRANCH: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.head.ref }} | |
run: | | |
echo "$BRANCH" | |
push-and-pull-request: | |
if: github.event_name == 'pull_request' || github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: get tag | |
env: | |
TAG: ${{ github.event_name == 'push' && github.ref_name || format('pr-{0}', github.event.number) }} # branch for push and pr-xx for pull request | |
run: | | |
echo "event_name: ${{ github.event_name }}, tag: $TAG" | |
label: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
env: | |
SKIP: 'FALSE' | |
steps: | |
- if: ${{ github.event.action == 'labeled' && !contains(toJson('["test", "build"]'), github.event.label.name) }} | |
id: skip | |
name: ignore unrelavant labels | |
run: | | |
echo "SKIP=TRUE" >> "$GITHUB_ENV" | |
echo "- github.event.action : ${{ github.event.action }}" >> "$GITHUB_STEP_SUMMARY" | |
echo "- github.event.label.name : ${{ github.event.label.name }}" >> "$GITHUB_STEP_SUMMARY" | |
- name: Dump GitHub context | |
if: ${{ env.SKIP != 'TRUE' }} | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: | | |
echo "$GITHUB_CONTEXT" | |
echo "- github.event.action : ${{ github.event.action }}" >> "$GITHUB_STEP_SUMMARY" | |
- if: ${{ contains( github.event.pull_request.labels.*.name, 'test') }} | |
name: check if a pr has test label | |
run: | | |
echo "- github.event.pull_request.labels has 'test'" >> "$GITHUB_STEP_SUMMARY" | |
- name: write sha as comment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `github.event_name: ${{ github.event_name }} (github.event.action: ${{ github.event.action }})\n- github.event.pull_request.head.sha: ${{ github.event.pull_request.head.sha }}\n - github.sha: ${{ github.sha }}` | |
}) |