diff --git a/clone_from/action.yml b/clone_from/action.yml index 032c5cd..f7770cb 100644 --- a/clone_from/action.yml +++ b/clone_from/action.yml @@ -1,4 +1,4 @@ -name: Clone a GitHub repository. +name: Clone from a GitHub repository. inputs: owner: @@ -19,18 +19,20 @@ runs: steps: - - name: Cloning ${{ inputs.slug }} + - name: Cloning ${{ inputs.branch }} from ${{ inputs.owner }}/${{ inputs.repo }} shell: bash - env: - GH_TOKEN: ${{ github.token }} - SLUG: ${{ inputs.owner }}/${{ inputs.repo }} run: | export GIT_TERMINAL_PROMPT=0 export GCM_INTERACTIVE=Never + if [[ -z "${{ inputs.owner }}" ]]; then echo "Missing owner value!"; exit 1; fi + if [[ -z "${{ inputs.repo }}" ]]; then echo "Missing repo value!"; exit 1; fi + if [[ -z "${{ inputs.branch }}" ]]; then echo "Missing branch value!"; exit 1; fi + if [[ -z "${{ inputs.checkout }}" ]]; then echo "Missing checkout value!"; exit 1; fi + cd .. - time rm -rf ${{ inputs.repo }} + time rm -rf "${{ inputs.repo }}" git config --global gc.auto 0 git config --global fetch.recurseSubmodules false @@ -40,22 +42,23 @@ runs: cat ~/.gitconfig # Checkout if needed - if [[ '${{ inputs.checkout }}' != 'true' ]]; then - GIT_CLONE_ARGS="--no-checkout" + export GIT_ARGS='' + if [[ "x${{ inputs.checkout }}" != 'xtrue' ]]; then + export GIT_ARGS="--no-checkout" fi - # Clone a blobless repository and don't bother checking it out. + # Clone a blobless repository. set -x time git clone \ - $GIT_CLONE_ARGS \ + $GIT_ARGS \ --filter=blob:none \ --no-tags \ --origin upstream \ - --branch ${{ inputs.branch }} \ + --branch "${{ inputs.branch }}" \ --verbose \ - https://token:${GH_TOKEN}@github.com/${SLUG}.git + "https://token:${{ github.token }}@github.com/${{ inputs.owner }}/${{ inputs.repo }}.git" set +x # Enter cloned repository - cd ${{ inputs.repo }} + cd "${{ inputs.repo }}" ls -l . diff --git a/push_to/action.yml b/push_to/action.yml index 2b6fd71..4034dac 100644 --- a/push_to/action.yml +++ b/push_to/action.yml @@ -1,9 +1,9 @@ -name: Push to repository. +name: Push to a GitHub repository. inputs: owner: description: GitHub username who owns the repository. - default: ${{ github.event.repository.owner.name }} + default: ${{ github.event.repository.owner.login }} repo: description: GitHub repo name. default: ${{ github.event.repository.name }} @@ -22,21 +22,31 @@ runs: steps: - - name: Pushing ${{ inputs.branch }} to ${{ inputs.slug }} + - name: Pushing ${{ inputs.branch }} from ${{ inputs.owner }}/${{ inputs.repo }} shell: bash run: | + export GIT_TERMINAL_PROMPT=0 + export GCM_INTERACTIVE=Never if [[ -z "${{ inputs.owner }}" ]]; then echo "Missing owner value!"; exit 1; fi if [[ -z "${{ inputs.repo }}" ]]; then echo "Missing repo value!"; exit 1; fi if [[ -z "${{ inputs.branch }}" ]]; then echo "Missing branch value!"; exit 1; fi + if [[ -z "${{ inputs.force }}" ]]; then echo "Missing force value!"; exit 1; fi if [[ -z "${{ inputs.deployToken }}" ]]; then echo "Missing deployToken value!"; exit 1; fi # Figure out if we should do a force push export GIT_ARGS='' - if [[ x${{ inputs.force }} = 'xtrue' ]]; then + if [[ "x${{ inputs.force }}" = 'xtrue' ]]; then export GIT_ARGS=--force fi # Add local repository and push to it. - git remote add origin https://token:${{ inputs.deployToken }}@github.com/${{ inputs.owner }}/${{ inputs.repo }}.git - git push $GIT_ARGS origin --verbose ${{ inputs.branch }} + git remote add origin "https://token:${{ inputs.deployToken }}@github.com/${{ inputs.owner }}/${{ inputs.repo }}.git" + set -x + time git push \ + $GIT_ARGS \ + origin \ + --verbose \ + "${{ inputs.branch }}" + set +x +