Skip to content

Commit

Permalink
fixes issue where destination folder is a subdirectory (#1)
Browse files Browse the repository at this point in the history
* fixes issue where destination folder is a subdirectory
* adds test for destination subfolder
* ci tweaks
  • Loading branch information
leigholiver authored Dec 30, 2020
1 parent 4baa233 commit 03f345c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Create Tag

on:
push:
branches:
# explicit deny all here to make sure there isnt a commit loop
- '!*'
- main

jobs:
create_tag:
runs-on: ubuntu-latest
needs: run_tests
steps:
- name: Checkout
uses: actions/checkout@v2

- name: check if tag already exists
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* && git rev-parse "$(cat VERSION)" >/dev/null 2>&1 && exit 1 || exit 0

- name: create tag
run: git config --global user.email "${{ github.actor }}" && git config --global user.name "${{ github.actor }}" && git tag -a -m "$(cat VERSION)" $(cat VERSION) && git push --follow-tags
20 changes: 12 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: Test and Tag
name: Run tests

on:
push:
branches:
# explicit deny all here to make sure there isnt a commit loop
- '!*'
- main
- fix/*

jobs:
test_and_tag:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: check if tag already exists
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* && git rev-parse "$(cat VERSION)" >/dev/null 2>&1 && exit 1 || exit 0

- name: create test file
run: echo $(date) > tmp.txt

Expand Down Expand Up @@ -52,6 +50,15 @@ jobs:
destination_folder: destination
deploy_key: ${{ secrets.DEPLOY_KEY }}

- name: test destination subdirectory
uses: ./
with:
source: tmp
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: destination_subdirectory_test
destination_folder: destination/destination_sub
deploy_key: ${{ secrets.DEPLOY_KEY }}

- name: test destination directory with removal
uses: ./
with:
Expand All @@ -78,6 +85,3 @@ jobs:
destination_branch: commit_message_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
commit_message: testing a custom commit message (${{ github.sha }})

- name: create tag
run: git config --global user.email "${{ github.actor }}" && git config --global user.name "${{ github.actor }}" && git tag -a -m "$(cat VERSION)" $(cat VERSION) && git push --follow-tags
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.1
v1.0.2
5 changes: 2 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ fi
# set up some directories
CALLING_DIR=$(pwd)
WORKING_DIR=$(mktemp -d)
REAL_DESTINATION=$(realpath $WORKING_DIR/$INPUT_DESTINATION_FOLDER)/

# set up the github deploy key
mkdir -p ~/.ssh
Expand All @@ -30,8 +29,8 @@ cd $WORKING_DIR
git checkout $INPUT_DESTINATION_BRANCH || git checkout -b $INPUT_DESTINATION_BRANCH

# ensure destination directory exists, and is emptied if appropriate
mkdir -p $REAL_DESTINATION
cd $REAL_DESTINATION
mkdir -p $INPUT_DESTINATION_FOLDER
cd $INPUT_DESTINATION_FOLDER
if [ "${INPUT_DELETE_DESTINATION}" = "true" ]; then
git rm -rf .
fi
Expand Down

0 comments on commit 03f345c

Please sign in to comment.