-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hikaru Kawayoke
authored and
Hikaru Kawayoke
committed
Oct 21, 2019
0 parents
commit e061a93
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Container image that runs your code | ||
FROM ubuntu:18.04 | ||
|
||
# Copies your code file from your action repository to the filesystem path `/` of the container | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
zip \ | ||
sshpass | ||
|
||
# Code file to execute when the docker container starts up (`entrypoint.sh`) | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ZIP Deploy Action | ||
This action creates a zip file of a repository and upload it to a server and then unzip it in a specified location | ||
## Usage | ||
``` | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Deploy | ||
uses: y0ke/ZIP-Deploy-Action@master | ||
env: | ||
LOCAL_DIR: DIRECTORY_TO_DEPLOY | ||
REMOTE_DIR: REMOTE_DIR_TO_PUT | ||
EXCLUDE: "tests/* .gitattributes .gitignore" | ||
TARGET_SERVER: ${{ secrets.SERVER_NAME }} | ||
DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }} | ||
DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# action.yml | ||
name: 'zipSCPAction' | ||
description: 'Zip all files and deploy them to a server.' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh -l | ||
|
||
M_LOCAL_DIR=${LOCAL_DIR:-"./"} | ||
M_REMOTE_DIR=${REMOTE_DIR:-"~/"} | ||
M_TMP_DIR=${TMP_DIR:-"~/"} | ||
|
||
echo "Creating a zip files..." | ||
cd $M_LOCAL_DIR | ||
zip ~/dist.zip -r ./ -x \*/.git/\* $EXCLUDE | ||
cd ~/ | ||
echo "Zip file created." | ||
|
||
|
||
echo "Deploying files" | ||
|
||
sshpass -p $DEPLOY_PASSWORD scp -o StrictHostKeyChecking=no dist.zip ${DEPLOY_USERNAME}@${TARGET_SERVER}:${M_TMP_DIR} | ||
|
||
sshpass -p $DEPLOY_PASSWORD ssh ${DEPLOY_USERNAME}@${TARGET_SERVER} bash -c "' | ||
cd ${M_TMP_DIR} | ||
rm -rf tmp_zip | ||
mkdir tmp_zip | ||
unzip dist.zip -d tmp_zip | ||
cp -Rpf tmp_zip/. ${M_REMOTE_DIR} | ||
rm -rf tmp_zip | ||
rm dist.zip | ||
'" | ||
|
||
echo "Deploy completed" |