From 57e72f9b1b24989acd5d1356b29a86fabe70ba18 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Mon, 28 Dec 2020 23:10:57 +0000 Subject: [PATCH 01/11] test_and_tag from https://github.com/leigholiver/commit-with-deploy-key/commit/04f00341020449f29b924763773f514abd9a4e8d --- .github/workflows/test.yml | 83 -------------------------------------- Dockerfile | 10 ----- README.md | 45 --------------------- VERSION | 1 - action.yml | 51 ----------------------- entrypoint.sh | 53 ------------------------ tmp.txt | 1 + tmp2.txt | 1 + 8 files changed, 2 insertions(+), 243 deletions(-) delete mode 100644 .github/workflows/test.yml delete mode 100644 Dockerfile delete mode 100644 README.md delete mode 100644 VERSION delete mode 100644 action.yml delete mode 100755 entrypoint.sh create mode 100644 tmp.txt create mode 100644 tmp2.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 20c55da..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Test and Tag - -on: - push: - branches: - # explicit deny all here to make sure there isnt a commit loop - - '!*' - - main - -jobs: - test_and_tag: - 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 - - - name: create test directory - run: mkdir -p tmp && cp tmp.txt tmp && echo "second cool file" > tmp/tmp2.txt - - - name: test with file - uses: ./ - id: filetest - with: - source: tmp.txt - destination_repo: leigholiver/commit-with-deploy-key - destination_branch: file_test - deploy_key: ${{ secrets.DEPLOY_KEY }} - - - name: test commit hash output - run: echo "the commit hash for the file test is ${{ steps.filetest.outputs.commit_hash }}" - - - name: test with directory - uses: ./ - with: - source: tmp - destination_repo: leigholiver/commit-with-deploy-key - destination_branch: directory_test - deploy_key: ${{ secrets.DEPLOY_KEY }} - - - name: test destination directory - uses: ./ - with: - source: tmp - destination_repo: leigholiver/commit-with-deploy-key - destination_branch: destination_directory_test - destination_folder: destination - deploy_key: ${{ secrets.DEPLOY_KEY }} - - - name: test destination directory with removal - uses: ./ - with: - source: tmp - destination_repo: leigholiver/commit-with-deploy-key - destination_branch: destination_directory_test_with_delete - delete_destination: true - deploy_key: ${{ secrets.DEPLOY_KEY }} - - - name: test with different username - uses: ./ - with: - source: tmp.txt - destination_repo: leigholiver/commit-with-deploy-key - destination_branch: username_test - deploy_key: ${{ secrets.DEPLOY_KEY }} - git_username: some different user - - - name: test with different commit message - uses: ./ - with: - source: tmp.txt - destination_repo: leigholiver/commit-with-deploy-key - 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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index bee5730..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# Container image that runs your code -FROM alpine:3.10 - -RUN apk update && apk add git openssh-client - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md deleted file mode 100644 index 72f7778..0000000 --- a/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Commit with deploy key -Action to commit a file/directory to another repo using a deploy key. - -## Example usage -* Create an SSH key pair to use for the commits -* Add the public key to your destination repo as a deploy key with push access -* Add the private key to your source repo as a secret - -```yaml -uses: leigholiver/commit-with-deploy-key@v1.0.0 -with: - source: build_output - destination_folder: dist - destination_repo: leigholiver/commit-with-deploy-key - deploy_key: ${{ secrets.DEPLOY_KEY }} -``` - -## Inputs -### `source` -**Required** The file/directory to commit - -### `deploy_key` -**Required** Private SSH key to use for the commit. The public key must be added to the destination repostitory as a deploy key, with push access - -### `destination_repo` -**Required** Git repository to push changes to - -### `destination_folder` -Directory in the destination repo to push changes to (default `.`) - -### `destination_branch` -Branch in destination repo to push changes to (default `main`) - -### `delete_destination` -Delete destination directory contents before copy? (default `false`) - -### `git_username`/`git_email` -Github user to use for the commit (default: `${{ github.actor }}`) - -### `commit_message` -Commit message (default ` from `) - -## Outputs -### `commit_hash` -SHA hash of the generated commit diff --git a/VERSION b/VERSION deleted file mode 100644 index 0ec25f7..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -v1.0.0 diff --git a/action.yml b/action.yml deleted file mode 100644 index 971c6bb..0000000 --- a/action.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: 'Commit with deploy key' -description: 'Commit to another repository using a deploy key' -inputs: - source: - description: 'The file/directory to commit' - required: true - deploy_key: - description: 'Private SSH key. Public key must be added to the destination repostitory as a deploy key with push access' - required: true - destination_repo: - description: 'Git repository to push changes to' - required: true - destination_folder: - description: 'Directory in destination repo to push changes to' - required: false - default: '.' - destination_branch: - description: 'Branch in destination repo to push changes to (default `main`)' - required: false - default: 'main' - delete_destination: - description: 'Delete destination directory contents before copy? (default `false`)' - required: false - default: false - git_username: - description: 'Git username' - required: false - default: ${{ github.actor }} - git_email: - description: 'Git email address' - required: false - default: ${{ github.actor }} - commit_message: - description: 'Commit message' - required: false - default: "${{ github.job }} from https://github.com/${{ github.repository }}/commit/${{ github.sha }}" -outputs: - commit_hash: - description: 'The SHA hash of the generated commit' -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.source }} - - ${{ inputs.destination_repo }} - - ${{ inputs.destination_folder }} - - ${{ inputs.delete_destination }} - - ${{ inputs.deploy_key }} - - ${{ inputs.git_username }} - - ${{ inputs.git_email }} - - ${{ inputs.commit_message }} diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 913bc34..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -l -set -e - -if [ ! -f "${INPUT_SOURCE}" ] && [ ! -d "${INPUT_SOURCE}" ]; then - echo "No source specified" - exit 1 -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 -echo "${INPUT_DEPLOY_KEY}" > ~/.ssh/id_rsa -chmod 600 ~/.ssh/id_rsa - -# set up git -git config --global user.name "${INPUT_GIT_USERNAME}" -git config --global user.email "${INPUT_GIT_EMAIL}" -ssh-keyscan -H github.com > ~/.ssh/known_hosts -GIT_SSH='ssh -i /github/home/.ssh/id_rsa -o UserKnownHostsFile=/github/home/.ssh/known_hosts' - -# clone the repo into our working directory and cd to it -GIT_SSH_COMMAND=$GIT_SSH git clone git@github.com:$INPUT_DESTINATION_REPO.git $WORKING_DIR -cd $WORKING_DIR - -# checkout the destination branch, creating it if it doesn't exist -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 -if [ "${INPUT_DELETE_DESTINATION}" = "true" ]; then - git rm -rf . -fi - -# do the copy -if [ -f $CALLING_DIR/$INPUT_SOURCE ]; then - cp -a $CALLING_DIR/$INPUT_SOURCE . -elif [ -d $CALLING_DIR/$INPUT_SOURCE ]; then - cp -a $CALLING_DIR/$INPUT_SOURCE/* . -fi - -# commit and push -git add . -git commit -m "${INPUT_COMMIT_MESSAGE}" -GIT_SSH_COMMAND=$GIT_SSH git push -u origin $INPUT_DESTINATION_BRANCH - -# output the commit hash -echo "::set-output name=commit_hash::$(git rev-parse HEAD)" -exit 0 diff --git a/tmp.txt b/tmp.txt new file mode 100644 index 0000000..0fb6789 --- /dev/null +++ b/tmp.txt @@ -0,0 +1 @@ +Mon Dec 28 23:10:39 UTC 2020 diff --git a/tmp2.txt b/tmp2.txt new file mode 100644 index 0000000..e2eac02 --- /dev/null +++ b/tmp2.txt @@ -0,0 +1 @@ +second cool file From 7dd3b94546f9a9e13142efe8812e9ef833ccfbe0 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Wed, 30 Dec 2020 10:52:54 +0000 Subject: [PATCH 02/11] test_and_tag from https://github.com/leigholiver/commit-with-deploy-key/commit/4baa233c5be6e8643eb35ecb82c97eed26c826c6 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 0fb6789..bae66be 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Mon Dec 28 23:10:39 UTC 2020 +Wed Dec 30 10:52:36 UTC 2020 From bfb0df64ada1fc0f0f22aff207411d1c93fad3a6 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Wed, 30 Dec 2020 18:55:08 +0000 Subject: [PATCH 03/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/f28c2f3e7f181e9203068afaee6e7216aefbe93a --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index bae66be..7685539 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Wed Dec 30 10:52:36 UTC 2020 +Wed Dec 30 18:54:47 UTC 2020 From 53f63af8f01ce186f46accf8da8c456d9d1a3679 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Wed, 30 Dec 2020 18:58:28 +0000 Subject: [PATCH 04/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/03f345cc8fa449263ce5e44cd6b526db9378322f --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 7685539..c6bc05a 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Wed Dec 30 18:54:47 UTC 2020 +Wed Dec 30 18:58:06 UTC 2020 From 00fc0de580e4dd5a0ee7aa6c8c5dd7547a5b869b Mon Sep 17 00:00:00 2001 From: leigholiver Date: Wed, 30 Dec 2020 19:02:29 +0000 Subject: [PATCH 05/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/af931f6193bc980f5e7eb92b66d3c7b12c0f6715 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index c6bc05a..8bc8eca 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Wed Dec 30 18:58:06 UTC 2020 +Wed Dec 30 19:02:08 UTC 2020 From 3d4085b0c075285d66b9a41e3bd293ff52312d4a Mon Sep 17 00:00:00 2001 From: leigholiver Date: Thu, 28 Apr 2022 10:55:28 +0000 Subject: [PATCH 06/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/b43b619240e653b67416afe566732cb4fffe51ba --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 8bc8eca..20ef094 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Wed Dec 30 19:02:08 UTC 2020 +Thu Apr 28 10:55:06 UTC 2022 From 8caaa404ef18e02e03332c45221ac565e4cf8c5f Mon Sep 17 00:00:00 2001 From: leigholiver Date: Thu, 28 Apr 2022 11:05:23 +0000 Subject: [PATCH 07/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/a637ac7ba7a220cb8488a5b0e802642be343e1fb --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 20ef094..add2fe6 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Thu Apr 28 10:55:06 UTC 2022 +Thu Apr 28 11:05:03 UTC 2022 From c0115e187b8bd338f109e53d294a387b1a993cf2 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Thu, 28 Apr 2022 12:03:03 +0000 Subject: [PATCH 08/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/3cef6ba75449633eab30cb6241dda84ed07e67c8 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index add2fe6..7c73ee9 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Thu Apr 28 11:05:03 UTC 2022 +Thu Apr 28 12:02:44 UTC 2022 From 5c6e99bee350fccfee05712101ee67df79c0ce30 Mon Sep 17 00:00:00 2001 From: leigholiver Date: Thu, 28 Apr 2022 13:58:03 +0000 Subject: [PATCH 09/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/15d8bec8e695d0b96cb320b013969e6f381d0919 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 7c73ee9..6460b97 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Thu Apr 28 12:02:44 UTC 2022 +Thu Apr 28 13:57:51 UTC 2022 From 90e050a8b1252bb38fea2ed0c52d25d24280727c Mon Sep 17 00:00:00 2001 From: leigholiver Date: Thu, 28 Apr 2022 14:01:44 +0000 Subject: [PATCH 10/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/9562ffd1c0965c6d4f264e2555a569bd33ac7d05 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 6460b97..281b100 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Thu Apr 28 13:57:51 UTC 2022 +Thu Apr 28 14:01:32 UTC 2022 From d5ddd9160e1a98da2e797e3fd16eb9a279e97c7a Mon Sep 17 00:00:00 2001 From: leigholiver Date: Tue, 12 Mar 2024 14:20:41 +0000 Subject: [PATCH 11/11] run_tests from https://github.com/leigholiver/commit-with-deploy-key/commit/64d2c8705aa10aa475e971b877a7fe6ada69a1a2 --- tmp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.txt b/tmp.txt index 281b100..c7aa326 100644 --- a/tmp.txt +++ b/tmp.txt @@ -1 +1 @@ -Thu Apr 28 14:01:32 UTC 2022 +Tue Mar 12 14:20:22 UTC 2024