end-to-end/actions/example-pull-request/.forgejo/workflows/test.yml
Renovate Bot ec2d8e96b7 Replace Node.js with data.forgejo.org/oci/node (#1239)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [code.forgejo.org/oci/node](https://hub.docker.com/_/node) ([source](https://github.com/nodejs/docker-node)) → [data.forgejo.org/oci/node](https://hub.docker.com/_/node) | container | replacement | `22-bookworm` -> `22-bookworm` |
| [code.forgejo.org/oci/node](https://hub.docker.com/_/node) ([source](https://github.com/nodejs/docker-node)) → [data.forgejo.org/oci/node](https://hub.docker.com/_/node) | container | replacement | `20-bookworm` -> `20-bookworm` |
| [code.forgejo.org/oci/node](https://hub.docker.com/_/node) ([source](https://github.com/nodejs/docker-node)) → [data.forgejo.org/oci/node](https://hub.docker.com/_/node) | final | replacement | `20-bookworm` -> `20-bookworm` |

This is a special PR that replaces `code.forgejo.org/oci/node` with the community suggested minimal stable replacement version.

---

### Configuration

📅 **Schedule**: Branch creation - "" (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xMS4wIiwidXBkYXRlZEluVmVyIjoiNDIuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/1239
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Renovate Bot <bot@kriese.eu>
Co-committed-by: Renovate Bot <bot@kriese.eu>
2025-12-01 15:41:41 +00:00

157 lines
5.3 KiB
YAML

on:
pull_request:
pull_request_target:
types:
- opened
- synchronize
jobs:
test:
runs-on: docker
container:
image: data.forgejo.org/oci/node:20-bookworm
options: "--volume /srv/example:/srv/example"
steps:
- name: setup
shell: bash
run: |
set -x
test $FORGEJO_TOKEN = ${{ env.FORGEJO_TOKEN }}
test $FORGEJO_TOKEN = ${{ forgejo.token }}
export DEBIAN_FRONTEND=noninteractive ; apt-get -qq update ; apt-get install -y -qq curl git >& /dev/null
curl -sS -o /usr/local/bin/forgejo-curl.sh https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh && chmod +x /usr/local/bin/forgejo-curl.sh
forgejo-curl.sh --token "$FORGEJO_TOKEN" login $FORGEJO_SERVER_URL
forgejo-curl.sh api_json $FORGEJO_SERVER_URL/api/v1/user
- name: determine if the PR is from a fork
id: forked
run: |
if test ${{ forgejo.event.pull_request.base.repo.full_name }} = ${{ forge.event.pull_request.head.repo.full_name }} ; then
echo value=false >> $FORGEJO_OUTPUT
else
echo value=true >> $FORGEJO_OUTPUT
fi
# See also actions/example-context/.forgejo/workflows/test.yml
- name: env.FORGEJO_BASE_REF
run: |
set -x
test "$FORGEJO_BASE_REF" = main
test "$FORGEJO_BASE_REF" = "${{ env.FORGEJO_BASE_REF }}"
# See also actions/example-context/.forgejo/workflows/test.yml
- name: env.FORGEJO_HEAD_REF
run: |
set -x
if ${{ steps.forked.outputs.value }} ; then
test "$FORGEJO_HEAD_REF" = main
else
test "$FORGEJO_HEAD_REF" = other
fi
test "$FORGEJO_HEAD_REF" = "${{ env.FORGEJO_HEAD_REF }}"
- name: secrets
shell: bash
run: |
set -x
case $FORGEJO_EVENT_NAME in
pull_request_target)
#
# all PRs: secrets
#
test "${{ secrets.SECRET }}"
;;
pull_request)
if ${{ steps.forked.outputs.value }} ; then
#
# PRs from forked repositories: no secrets
#
test -z "${{ secrets.SECRET }}"
else
#
# PRs from the same repository: secrets
#
test "${{ secrets.SECRET }}"
fi
;;
*)
echo unexpected event $FORGEJO_EVENT_NAME
false
;;
esac
- name: PR TOKEN scopes
shell: bash
run: |
set -x
function assert_fail_if_forked() {
if "$@" ; then
! ${{ steps.forked.outputs.value }}
else
${{ steps.forked.outputs.value }}
fi
}
#
# create an issue
#
base_repo=${{ forgejo.event.pull_request.base.repo.full_name }}
forgejo-curl.sh api_json --data-raw '{"title":"ISSUE"}' $FORGEJO_SERVER_URL/api/v1/repos/$base_repo/issues
url=$(echo $FORGEJO_SERVER_URL | sed -e "s|://|://$FORGEJO_TOKEN@|")
git clone $url/$base_repo base
branch=B$RANDOM
(
cd base
git checkout -b $branch
git config user.email root@example.com
git config user.name username
echo CHANGE >> README
git add .
git commit -m 'change'
case $FORGEJO_EVENT_NAME in
pull_request_target|pull_request)
#
# repository write scope via http git passthrough
#
assert_fail_if_forked git push --force -u origin $branch
#
# repository write scope via the API
#
assert_fail_if_forked forgejo-curl.sh api_json --data-raw '{"title":"PR","base":"main","head":"'$branch'"}' $FORGEJO_SERVER_URL/api/v1/repos/$base_repo/pulls
assert_fail_if_forked forgejo-curl.sh api_json --data-raw '{"color":"#ffffff","name":"labelname"}' $FORGEJO_SERVER_URL/api/v1/repos/$base_repo/labels
#
# See https://codeberg.org/forgejo/forgejo/issues/1525
#
! forgejo-curl.sh api_json --data-raw '{"new_branch_name":"B'$RANDOM'"}' $FORGEJO_SERVER_URL/api/v1/repos/$base_repo/branches
;;
*)
echo unexpected event $FORGEJO_EVENT_NAME
false
;;
esac
)
- name: save event
run: |
d=/srv/example/pull-request/contexts/${{ forgejo.event.pull_request.head.repo.owner.username }}/$FORGEJO_EVENT_NAME
mkdir -p $d
cat > $d/github <<'EOF'
${{ toJSON(github) }}
EOF
- uses: https://data.forgejo.org/actions/checkout@v4
- name: checkout the default branch if pull_request_target
run: |
set -x
case $FORGEJO_EVENT_NAME in
pull_request_target)
! test -f file-unique-to-the-pr-branch
;;
pull_request)
test -f file-unique-to-the-pr-branch
;;
*)
echo unexpected event $FORGEJO_EVENT_NAME
false
;;
esac