gh act tests #1522
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: gh act tests | |
on: | |
branch_protection_rule: | |
create: | |
check_run: | |
check_suite: | |
# delete: | |
discussion: | |
discussion_comment: | |
gollum: | |
issue_comment: | |
issues: | |
label: | |
merge_group: | |
milestone: | |
page_build: | |
public: | |
pull_request: | |
types: | |
- assigned | |
- unassigned | |
- labeled | |
- unlabeled | |
- opened | |
- edited | |
- closed | |
- reopened | |
- synchronize | |
- converted_to_draft | |
- ready_for_review | |
- locked | |
- unlocked | |
- review_requested | |
- review_request_removed | |
- auto_merge_enabled | |
- auto_merge_disabled | |
pull_request_review: | |
pull_request_review_comment: | |
pull_request_target: | |
types: | |
- assigned | |
- unassigned | |
- labeled | |
- unlabeled | |
- opened | |
- edited | |
- closed | |
- reopened | |
- synchronize | |
- converted_to_draft | |
- ready_for_review | |
- locked | |
- unlocked | |
- review_requested | |
- review_request_removed | |
- auto_merge_enabled | |
- auto_merge_disabled | |
push: | |
registry_package: | |
release: | |
repository_dispatch: | |
types: [on-demand-test] | |
schedule: | |
- cron: '0 0 * * 0' | |
status: | |
watch: | |
workflow_dispatch: | |
inputs: | |
event: | |
description: 'event name' | |
default: 'workflow_dispatch' | |
required: true | |
workflow_run: | |
workflows: [Lint] | |
types: | |
- requested | |
- completed | |
# https://github.com/srz-zumix/gh-act/issues/57 | |
permissions: write-all | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ACT_EVENT_NAME: ${{ inputs.event || github.event_name }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ (contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref) || github.ref }} | |
fetch-depth: 0 | |
- name: Install gh | |
run: | | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
apt update | |
apt install gh | |
if: ${{ env.ACT }} | |
- name: Install act | |
run: | | |
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | |
echo "./bin" >> "${GITHUB_PATH}" | |
{ | |
echo "-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest" | |
echo "-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04" | |
echo "-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04" | |
} > .actrc | |
- name: Install gh-act | |
run: | | |
make install | |
- name: Dump github.event | |
run: | | |
jq . < "${GITHUB_EVENT_PATH}" | tee github_event.json | |
- name: Create act event.json | |
run: | | |
gh act "${ACT_EVENT_NAME}" -e gh_act_event_raw.json -j noop | |
jq . < gh_act_event_raw.json | tee gh_act_event.json | |
- name: Diff | |
run: | | |
diff github_event.json gh_act_event.json || : | |
if: github.event_name == env.ACT_EVENT_NAME | |
- name: Docker ps | |
run: | | |
docker ps | |
noop: | |
runs-on: ubuntu-latest | |
# jobs.*.if では env 参照できない | |
# actor で判断している | |
if: github.actor == 'nektos/act' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ (contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref) || github.ref }} |