diff --git a/README.md b/README.md index e69de29..0f325e4 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,41 @@ +# Checkout GitHub Action + +This composite GitHub Action allows you to **clone** and **check out** the current repository using the Git CLI. The action uses the GitHub-provided `GITHUB_TOKEN` for authentication, ensuring secure and seamless access. + +## Features + +- Clones the repository using HTTP. +- Checks out the specified branch or reference (`${{ github.ref }}`). +- Utilizes GitHub's built-in secrets for secure access. + +## Usage + +### Example Workflow + +```yaml +name: Example Workflow + +on: + push: + branches: + - main + +jobs: + checkout-job: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: ./ +``` + +### Inputs + +No custom inputs are required. The action uses environment variables provided by GitHub Actions: + +| Variable | Description | +|--------------------|-----------------------------------------------------------| +| `github.server_url` | The URL of the GitHub server. | +| `github.token` | Automatically provided GitHub token for authentication. | +| `github.repository` | The repository name (`owner/repo`). | +| `github.workspace` | The working directory for the workflow. | +| `github.ref` | The branch or tag to check out. | diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..77f64c2 --- /dev/null +++ b/action.yml @@ -0,0 +1,17 @@ +name: 'Checkout' +description: 'Checkout the current repository' +runs: + using: "composite" + steps: + - name: Clone Repository + shell: sh + run: | + URL_WITH_HTTP=${{ github.server_url }} + URL=${URL_WITH_HTTP#http://} + URL=${URL#https://} + git clone http://wf:${{ github.token }}@${URL}/${{ github.repository }}.git ${{ github.workspace }} + - name: Checkout Repository + shell: sh + run: | + cd ${{ github.workspace }} + git checkout ${{ github.ref }}