diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..61a8dc8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +minimum_pre_commit_version: "3.0.0" + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer diff --git a/Dockerfile b/Dockerfile index ed51e85..b056a80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ FROM alpine:3.20 +RUN apk add git COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index af4ed90..3442cd3 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,15 @@ -# Checkout action +# Checkout V1 -This action checkout project's code. +This action clones project's code under __$GITHUB_WORKSPACE__. -## Inputs - -None - -## Outputs - -None - -## Example usage +## Usage +```yaml +- uses: actions/checkout@v1 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -uses: actions/checkout@v1 -``` + +## Environment variables + +To checks out a private repo, __GH_TOKEN__ must be configured with an authentication token with read permissions. diff --git a/action.yml b/action.yml index 77661d9..1355574 100644 --- a/action.yml +++ b/action.yml @@ -2,4 +2,4 @@ name: Checkout description: Checkout code. runs: using: docker - image: docker://test:latest + image: Dockerfile diff --git a/entrypoint.sh b/entrypoint.sh index 05f0a6a..fe04fe0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,3 +1,7 @@ #!/bin/sh -l -env -pwd \ No newline at end of file + +git version + +[ -z "$GH_TOKEN" ] \ + && git clone --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} ./ \ + || git clone --branch ${GITHUB_REF_NAME} $(echo ${GITHUB_SERVER_URL} | sed -r "s|(https*://)|\1${GH_TOKEN}@|")/${GITHUB_REPOSITORY} ./