actions: add context example
This commit is contained in:
parent
c5cccca38d
commit
4768908489
8 changed files with 240 additions and 4 deletions
|
@ -1 +0,0 @@
|
|||
ONE
|
188
actions/example-context/.forgejo/workflows/test.yml
Normal file
188
actions/example-context/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,188 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
steps:
|
||||
|
||||
- name: env.CI
|
||||
run: |
|
||||
set -x
|
||||
test "$CI" = true
|
||||
test "$CI" = "${{ env.CI }}"
|
||||
|
||||
- name: env.GITHUB_ACTION
|
||||
run: |
|
||||
set -x
|
||||
echo "$GITHUB_ACTION" | grep -E '^[0-9]+$'
|
||||
test "$GITHUB_ACTION" = "${{ env.GITHUB_ACTION }}"
|
||||
|
||||
# See also actions/example-local-action/.forgejo/local-action/action.yml
|
||||
- name: env.GITHUB_ACTION_PATH
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_ACTION_PATH"
|
||||
test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}"
|
||||
|
||||
- name: when running an action
|
||||
if: ${{ env.GITHUB_ACTIONS }}
|
||||
uses: SELF@main
|
||||
with:
|
||||
input-one: "otherone"
|
||||
|
||||
- name: env.GITHUB_ACTION_REPOSITORY
|
||||
run: test -f /srv/example/example-context/GITHUB_ACTION_REPOSITORY
|
||||
|
||||
- name: env.GITHUB_ACTION_PATH
|
||||
run: test -f /srv/example/example-context/GITHUB_ACTION_PATH
|
||||
|
||||
- name: env.GITHUB_ACTIONS
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTIONS" = true
|
||||
test "$GITHUB_ACTIONS" = "${{ env.GITHUB_ACTIONS }}"
|
||||
|
||||
- name: env.GITHUB_ACTOR
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTOR"
|
||||
test "$GITHUB_ACTOR" = "${{ env.GITHUB_ACTOR }}"
|
||||
|
||||
- name: env.GITHUB_API_URL
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_API_URL" =~ /api/v1$ ]]
|
||||
test "$GITHUB_API_URL" = "${{ env.GITHUB_API_URL }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: env.GITHUB_BASE_REF
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_BASE_REF"
|
||||
test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: env.GITHUB_HEAD_REF
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_HEAD_REF"
|
||||
test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}"
|
||||
|
||||
- name: env.GITHUB_ENV
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_ENV"
|
||||
test "$GITHUB_ENV" = "${{ env.GITHUB_ENV }}"
|
||||
|
||||
- name: env.GITHUB_EVENT_NAME
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_EVENT_NAME" = push
|
||||
test "$GITHUB_EVENT_NAME" = "${{ env.GITHUB_EVENT_NAME }}"
|
||||
|
||||
- name: env.GITHUB_JOB
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_JOB" = test
|
||||
test "$GITHUB_JOB" = "${{ env.GITHUB_JOB }}"
|
||||
|
||||
- name: env.GITHUB_OUTPUT
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_OUTPUT"
|
||||
test "$GITHUB_OUTPUT" = "${{ env.GITHUB_OUTPUT }}"
|
||||
|
||||
- name: env.GITHUB_PATH
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_PATH"
|
||||
test "$GITHUB_PATH" = "${{ env.GITHUB_PATH }}"
|
||||
|
||||
- name: env.GITHUB_REF
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_REF" =~ ^refs/ ]]
|
||||
test "$GITHUB_REF" = "${{ env.GITHUB_REF }}"
|
||||
|
||||
- name: env.GITHUB_REF_NAME
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
! [[ "$GITHUB_REF_NAME" =~ ^refs/ ]]
|
||||
test "$GITHUB_REF_NAME" = "${{ env.GITHUB_REF_NAME }}"
|
||||
|
||||
- name: env.GITHUB_REPOSITORY
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_REPOSITORY" = root/example-context
|
||||
test "$GITHUB_REPOSITORY" = "${{ env.GITHUB_REPOSITORY }}"
|
||||
|
||||
- name: env.GITHUB_REPOSITORY_OWNER
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_REPOSITORY_OWNER" = root
|
||||
test "$GITHUB_REPOSITORY_OWNER" = "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
||||
|
||||
- name: env.GITHUB_RUN_NUMBER
|
||||
run: |
|
||||
set -x
|
||||
echo "$GITHUB_RUN_NUMBER" | grep -E '^[0-9]+$'
|
||||
test "$GITHUB_RUN_NUMBER" = "${{ env.GITHUB_RUN_NUMBER }}"
|
||||
|
||||
- name: env.GITHUB_SERVER_URL
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_SERVER_URL" =~ ^http ]]
|
||||
test "$GITHUB_SERVER_URL" = "${{ env.GITHUB_SERVER_URL }}"
|
||||
|
||||
- name: env.GITHUB_SHA
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_SHA"
|
||||
test "$GITHUB_SHA" = "${{ env.GITHUB_SHA }}"
|
||||
|
||||
- name: env.GITHUB_STEP_SUMMARY
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_STEP_SUMMARY"
|
||||
test "$GITHUB_STEP_SUMMARY" = "${{ env.GITHUB_STEP_SUMMARY }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: env.GITHUB_TOKEN
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_TOKEN"
|
||||
test "$GITHUB_TOKEN" = "${{ env.GITHUB_TOKEN }}"
|
||||
|
||||
- name: env.GITHUB_WORKSPACE
|
||||
run: |
|
||||
set -x
|
||||
test -d "$GITHUB_WORKSPACE"
|
||||
test "$GITHUB_WORKSPACE" = "${{ env.GITHUB_WORKSPACE }}"
|
||||
|
||||
- name: RUNNER_ARCH
|
||||
run: |
|
||||
set -x
|
||||
test "$RUNNER_ARCH" = X64
|
||||
|
||||
- name: RUNNER_OS
|
||||
run: |
|
||||
set -x
|
||||
test "$RUNNER_OS" = Linux
|
||||
|
||||
# runner 3.3.0 $RUNNER_TOOL_CACHE is not an existing directory
|
||||
# - name: RUNNER_TOOL_CACHE
|
||||
# run: |
|
||||
# set -x
|
||||
# test -d "$RUNNER_TOOL_CACHE"
|
||||
|
||||
- name: RUNNER_TEMP
|
||||
run: |
|
||||
set -x
|
||||
test -d "$RUNNER_TEMP"
|
21
actions/example-context/action-for-context/action.yml
Normal file
21
actions/example-context/action-for-context/action.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
inputs:
|
||||
input-one:
|
||||
default: 'one'
|
||||
description: 'description one'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: GITHUB_ACTION_REPOSITORY
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTION_REPOSITORY" = root/action-for-context
|
||||
test "$GITHUB_ACTION_REPOSITORY" = "${{ env.GITHUB_ACTION_REPOSITORY }}"
|
||||
touch /srv/example/example-context/GITHUB_ACTION_REPOSITORY
|
||||
|
||||
- name: GITHUB_ACTION_PATH
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_ACTION_PATH" =~ action-for-context@main$ ]]
|
||||
touch /srv/example/example-context/GITHUB_ACTION_PATH
|
1
actions/example-context/run.sh
Normal file
1
actions/example-context/run.sh
Normal file
|
@ -0,0 +1 @@
|
|||
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example action-for-context $token
|
3
actions/example-context/setup.sh
Normal file
3
actions/example-context/setup.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
mkdir -p /srv/example/example-context
|
||||
|
||||
forgejo-test-helper.sh push actions/example-$example/action-for-context $url root action-for-context
|
Loading…
Add table
Reference in a new issue