Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hikaru Kawayoke authored and Hikaru Kawayoke committed Oct 21, 2019
0 parents commit e061a93
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
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"]
24 changes: 24 additions & 0 deletions README.md
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 }}
```
6 changes: 6 additions & 0 deletions action.yaml
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'
28 changes: 28 additions & 0 deletions entrypoint.sh
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"

0 comments on commit e061a93

Please sign in to comment.