Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/actions/deploy-dir-as-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ runs:
- name: Creating temporary directory to clone the branch
shell: bash
run: |
BRANCH_DIR=$(mktemp -d "`pwd`/cloned_${{ inputs.target_branch }}_XXXXXX")
BRANCH_DIR=$(mktemp -d "`pwd`/$BRANCH_DIR_TEMPLATE")
echo "BRANCH_DIR=$BRANCH_DIR" >> $GITHUB_ENV
env:
BRANCH_DIR_TEMPLATE: 'cloned_${{ inputs.target_branch }}_XXXXXX'

- name: Checkout `${{ inputs.target_branch }}` branch
uses: actions/checkout@v2
Expand All @@ -31,7 +33,7 @@ runs:
echo '::endgroup::'

echo '::group::Move necessary files'
cp -vnR '${{ github.workspace }}/${{ inputs.src_dir }}/.' .
cp -vnR "$SRC_DIR/." .
echo '::endgroup::'

git add -A
Expand All @@ -41,12 +43,16 @@ runs:
git config user.name 'GitHub Action Script'
git config user.email '[email protected]'

git commit -a -m 'Deploy ${{ github.sha }} to '${{ inputs.target_branch }}' branch'
git commit -a -m "Deploy $SHA to '$TARGET_BRANCH' branch"
git push
echo 'Pushed'
fi
env:
SRC_DIR: '${{ github.workspace }}/${{ inputs.src_dir }}'
SHA: ${{ github.sha }}
TARGET_BRANCH: ${{ inputs.target_branch }}

- name: Remove cloned branch
if: ${{ always() }}
shell: bash
run: 'rm -rf $BRANCH_DIR'
run: 'rm -rf "$BRANCH_DIR"'