forked from john-jam/checkout-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
50 lines (45 loc) · 1.9 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: "Checkout Action"
description: "Cleanup the remaining traces of previous jobs in self hosted runner and checkout the repository"
inputs:
actions-repo:
description: "The private actions repository to checkout in the .github/actions folder"
required: false
default: ""
actions-ssh-key:
description: "The ssh deploy key used to clone the actions private repository"
required: false
default: ""
fetch-depth:
description: "Number of commits to fetch. 0 indicates all history for all branches and tags."
required: false
default: 1
runs:
using: composite
steps:
# When mixing jobs on the host and inside containers, some folders could have root ownership and break the next builds
# https://github.com/actions/runner/issues/434#issuecomment-992865457
- name: Cleanup workspace
uses: docker://alpine
with:
args: /bin/sh -c "rm -rf /github/workspace/.* || rm -rf /github/workspace/*"
- name: Checkout the current repository
uses: actions/checkout@v4
with:
fetch-depth: inputs.fetch-depth
- name: Set variables
if: inputs.actions-repo != '' && inputs.actions-ssh-key != ''
id: actions-set-vars
shell: bash
run: |
repo_basepath=$(echo "${{ inputs.actions-repo }}" | cut -d '@' -f1)
repo_ref=$(echo "${{ inputs.actions-repo }}" | cut -d '@' -f2)
echo "repo-basepath=$(echo ${repo_basepath})" >> $GITHUB_OUTPUT
echo "repo-ref=$(echo ${repo_ref})" >> $GITHUB_OUTPUT
- name: Checkout the actions private repository
if: inputs.actions-repo != '' && inputs.actions-ssh-key != ''
uses: actions/checkout@v4
with:
repository: ${{ steps.actions-set-vars.outputs.repo-basepath }}
ref: ${{ steps.actions-set-vars.outputs.repo-ref }}
path: .github/actions/${{ steps.actions-set-vars.outputs.repo-basepath }}
ssh-key: ${{ inputs.actions-ssh-key }}