From 310ebb6d403511046629ccbd0c126e308a72f82b Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 12:53:01 +0100 Subject: [PATCH 01/11] ci: Fix (hopefully) run of nightly build for tag --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index a57b875..d857b0a 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -18,6 +18,7 @@ steps: password: from_secret: cb_token when: + - event: push - branch: develop publish-release: From b2b3569e7992be4294881fd0e5699db41647ea69 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 12:54:38 +0100 Subject: [PATCH 02/11] ci: Fix condition --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index d857b0a..a2237c7 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -19,7 +19,7 @@ steps: from_secret: cb_token when: - event: push - - branch: develop + branch: develop publish-release: image: woodpeckerci/plugin-docker-buildx From ecdecec5c62de52368675240eec06efac0180801 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:02:20 +0100 Subject: [PATCH 03/11] ci: Disable build step on develop and master Since build is inlcuded in publish jobs. --- .woodpecker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index a2237c7..b8bc783 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -6,6 +6,10 @@ steps: repo: git.merp.digital/${CI_REPO_OWNER}/woodpecker-scp platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x registry: git.merp.digital + when: + - event: push + branch: + exclude: [develop, master] publish-nightly: image: woodpeckerci/plugin-docker-buildx From 4e2763d775f9e78d57dc41a8615eb91b13da22f6 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:17:17 +0100 Subject: [PATCH 04/11] fix: SSH file permissions --- plugin.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.sh b/plugin.sh index d3b1b38..a196bfa 100644 --- a/plugin.sh +++ b/plugin.sh @@ -1,6 +1,9 @@ #!/bin/sh mkdir -p /root/.ssh +chmod 800 /root/.ssh echo "${PLUGIN_SSH_KEY}" > "/root/.ssh/id_rsa" +chmod 600 /root/.ssh/id_rsa echo "${PLUGIN_SSH_KNOWN_HOSTS}" > "/root/.ssh/known_hosts" +chmod 600 /root/.ssh/known_hosts scp -B ${PLUGIN_EXTRA_FLAGS} ${PLUGIN_SOURCE} ${PLUGIN_DESTINATION} \ No newline at end of file From 8a083f992d7afa26ae69527c7454e4e0d1f8eb72 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:20:31 +0100 Subject: [PATCH 05/11] fix: Add leading zero --- plugin.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.sh b/plugin.sh index a196bfa..708e83e 100644 --- a/plugin.sh +++ b/plugin.sh @@ -1,9 +1,9 @@ #!/bin/sh mkdir -p /root/.ssh -chmod 800 /root/.ssh +chmod 0800 /root/.ssh echo "${PLUGIN_SSH_KEY}" > "/root/.ssh/id_rsa" -chmod 600 /root/.ssh/id_rsa +chmod 0600 /root/.ssh/id_rsa echo "${PLUGIN_SSH_KNOWN_HOSTS}" > "/root/.ssh/known_hosts" -chmod 600 /root/.ssh/known_hosts +chmod 0600 /root/.ssh/known_hosts scp -B ${PLUGIN_EXTRA_FLAGS} ${PLUGIN_SOURCE} ${PLUGIN_DESTINATION} \ No newline at end of file From b54f434cb2984d1c811743ff726638d1cd75c234 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:25:32 +0100 Subject: [PATCH 06/11] fix: Remove ambigious chmod for directory --- plugin.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin.sh b/plugin.sh index 708e83e..7fb7cd8 100644 --- a/plugin.sh +++ b/plugin.sh @@ -1,7 +1,6 @@ #!/bin/sh mkdir -p /root/.ssh -chmod 0800 /root/.ssh echo "${PLUGIN_SSH_KEY}" > "/root/.ssh/id_rsa" chmod 0600 /root/.ssh/id_rsa echo "${PLUGIN_SSH_KNOWN_HOSTS}" > "/root/.ssh/known_hosts" From 2648c4c9a5e5c075c5168c466a16d6db6f99179c Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:28:13 +0100 Subject: [PATCH 07/11] fix: Make scp verbose, so progress can be tracked --- plugin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.sh b/plugin.sh index 7fb7cd8..361e971 100644 --- a/plugin.sh +++ b/plugin.sh @@ -5,4 +5,4 @@ echo "${PLUGIN_SSH_KEY}" > "/root/.ssh/id_rsa" chmod 0600 /root/.ssh/id_rsa echo "${PLUGIN_SSH_KNOWN_HOSTS}" > "/root/.ssh/known_hosts" chmod 0600 /root/.ssh/known_hosts -scp -B ${PLUGIN_EXTRA_FLAGS} ${PLUGIN_SOURCE} ${PLUGIN_DESTINATION} \ No newline at end of file +scp -Bv ${PLUGIN_EXTRA_FLAGS} ${PLUGIN_SOURCE} ${PLUGIN_DESTINATION} \ No newline at end of file From b62205be18229adbd1e2c40e53a8e4ba7426418f Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 13:58:04 +0100 Subject: [PATCH 08/11] docs: Add ReadMe --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..43823a5 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# woodpecker-scp +woodpecker-scp is a small plugin for weoodpecker, which allows users to upload diretories and files to any server that supports scp. + +## Usage +To use woodpecker-scp use the following entries in your `.woodpecker.yml`: + +```yaml +publish: + image: git.merp.digital/eranmorkon/woodpecker-scp:latest + settings: + ssh_key: + from_secret: ssh_key + ssh_known_hosts: + from_secret: ssh_known_hosts + extra_flags: -r + source: local-path + destination: "user@server:remote-path" +``` + +The plugin is published in the `git.merp.digital` oci registry, the `latest` tag is always the latest release, addidtionally release tags in the format `x.y.z` point to the specified releases. The `develop` tag always holds the latest commit to the develop branch and can therefore be seen as nighty, it is definitely not stable however. + +## Settings +### ssh_key +The SSH key holds the private key scp will use to connect to the server, I would recommend to generate a new private/public key pair for your CI job and add the contents of your private key file as secret. The add the public key to the server's `~/.ssh/authorized_keys` file as usual. + +### ssh_known_hosts +This should be the content of the `~/.ssh/known_hosts` file. This is used to let scp verify the identity of the remote server. If you skip this step the transfer will not work, as scp can not verify that the server you are connecting to is actually the server you want to connect to. You can disable this behaviour using `extra_flags` but I highly recommend to not do that, and instead add the `known_hosts` entry. + +### extra_flags +This setting is used to add extra flags to the scp command. Per default scp will be executed with the `-Bv` flags, for `batch mode` and `verbose` so you can see some output from scp in the CI log. You can add any flag that scp supports, for example `-r` for a recursive copy. + +### source +The source directory scp will copy the data from, this can be in the CI container, or on a remote server, however the later one is untested at the moment. + +### destination +The destination directory scp will copy the data to, this can be on a remote server, or in the CI container, however the later one is untested at the moment. + +## License +Licensed under the [MIT](https://choosealicense.com/licenses/mit/) license. + +`SPDX-License-Identifier: MIT` \ No newline at end of file From afd86aa76ce963d119a44a0b82ec72065e061778 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 14:04:02 +0100 Subject: [PATCH 09/11] docs: Add CI badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 43823a5..2644e7a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # woodpecker-scp +[![status-badge](https://ci.merp.digital/api/badges/2/status.svg)](https://ci.merp.digital/repos/2) + woodpecker-scp is a small plugin for weoodpecker, which allows users to upload diretories and files to any server that supports scp. ## Usage From b5b149ee137575e5ccb3477f958d8c4b547987d4 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 15:01:22 +0100 Subject: [PATCH 10/11] ci: Remove latest tag --- .woodpecker.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index b8bc783..ea0fd03 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,9 +7,9 @@ steps: platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x registry: git.merp.digital when: - - event: push - branch: - exclude: [develop, master] + - event: push + branch: + exclude: [develop, master] publish-nightly: image: woodpeckerci/plugin-docker-buildx @@ -17,7 +17,7 @@ steps: repo: git.merp.digital/${CI_REPO_OWNER}/woodpecker-scp platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x registry: git.merp.digital - tags: ${CI_COMMIT_BRANCH} + tags: develop-${CI_COMMIT_SHA} username: ${CI_REPO_OWNER} password: from_secret: cb_token @@ -31,9 +31,7 @@ steps: repo: git.merp.digital/${CI_REPO_OWNER}/woodpecker-scp platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x registry: git.merp.digital - tags: - - latest - - ${CI_COMMIT_TAG} + tags: ${CI_COMMIT_TAG} username: ${CI_REPO_OWNER} password: from_secret: cb_token From 50d070813a71adbd1b96eaa60963e44c9bd8f9f8 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Fri, 29 Dec 2023 15:39:32 +0100 Subject: [PATCH 11/11] docs: Bump Version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2644e7a..78845f7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To use woodpecker-scp use the following entries in your `.woodpecker.yml`: ```yaml publish: - image: git.merp.digital/eranmorkon/woodpecker-scp:latest + image: git.merp.digital/eranmorkon/woodpecker-scp:1.1.0 settings: ssh_key: from_secret: ssh_key