From 375bc6a9240bf778e77e8bacda0e0ecb16551304 Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Wed, 15 Apr 2020 16:46:57 -0400 Subject: [PATCH 1/4] Revert "Remove GitHub actions as they can no longer run (#1718)" This reverts commit 00564a8ac58dd72f22bef3c7c75c3b9838646d6a. --- .github/actions/deploy/Dockerfile | 10 +++++ .github/actions/deploy/deploy.yml | 23 ++++++++++ .github/actions/deploy/entrypoint.sh | 66 ++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 16 +++++++ 4 files changed, 115 insertions(+) create mode 100644 .github/actions/deploy/Dockerfile create mode 100644 .github/actions/deploy/deploy.yml create mode 100755 .github/actions/deploy/entrypoint.sh create mode 100644 .github/workflows/deploy.yml diff --git a/.github/actions/deploy/Dockerfile b/.github/actions/deploy/Dockerfile new file mode 100644 index 000000000..b6a5127f7 --- /dev/null +++ b/.github/actions/deploy/Dockerfile @@ -0,0 +1,10 @@ +FROM node:10.16.3-jessie + +RUN dpkg --add-architecture i386 +RUN apt update +RUN apt -y install python make libxkbfile-dev libxkbfile-dev:i386 libx11-dev libx11-dev:i386 libxss-dev gcc-multilib g++-multilib rpm + +COPY "entrypoint.sh" "/entrypoint.sh" +ENTRYPOINT ["/entrypoint.sh"] + +CMD [""] \ No newline at end of file diff --git a/.github/actions/deploy/deploy.yml b/.github/actions/deploy/deploy.yml new file mode 100644 index 000000000..c86272158 --- /dev/null +++ b/.github/actions/deploy/deploy.yml @@ -0,0 +1,23 @@ +name: 'Deploy Simplenote' +description: 'Builds and deploys Simplenote to VIP Go branches' +branding: + icon: 'truck' + color: 'green' +inputs: + APP_ID: + description: 'Application ID' + required: true + GITHUB_TOKEN: + description: 'GitHub Token' + requried: true + BRANCH: + description: 'Branch' + required: true +runs: + using: 'docker' + image: 'Dockerfile' + entrypoint: './.github/actions/deploy/entrypoint.sh' + env: + APP_ID: ${{ inputs.APP_ID }} + GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + BRANCH: ${{ inputs.BRANCH }} diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh new file mode 100755 index 000000000..f519f9ba5 --- /dev/null +++ b/.github/actions/deploy/entrypoint.sh @@ -0,0 +1,66 @@ +#!/bin/sh -l + +COMMIT_BRANCH='' +WEB_APP_URL='' +APP_ENGINE_URL='' + +case $BRANCH in + + "refs/heads/develop") + COMMIT_BRANCH='webapp-develop' + WEB_APP_URL='https://simplenote-develop.go-vip.net' + APP_ENGINE_URL='https://develop.simplenote.com' + ;; + + "refs/heads/master") + COMMIT_BRANCH='webapp' + WEB_APP_URL='https://simplenote.go-vip.co' + APP_ENGINE_URL='https://app.simplenote.com' + ;; + + *) + exit 0 + ;; +esac + +# Install Node Modules +npm install + +#Setup config-local to override config +json_string=$(printf '{"app_id": "%s", "app_key": "12345", "development": false, "wpcc_client_id": "0", "wpcc_redirect_url": "https://simplenote.com", "is_app_engine": true, "web_app_url": "%s", "app_engine_url": "%s"}' "$APP_ID" "$WEB_APP_URL" "$APP_ENGINE_URL") +echo "$json_string" > config-local.json + +# Build site +NODE_ENV=production make build + +# Variables +ORIGIN_URL=$(git config --get remote.origin.url) + +# Checkout deploy branch +if [ "$(git branch | grep $COMMIT_BRANCH)" ] +then + git branch -D $COMMIT_BRANCH +fi +git checkout -b $COMMIT_BRANCH + +# Delete files not needed in production +find . -maxdepth 1 ! -name '.git' ! -name 'dist' ! -name 'vip' -exec rm -rf {} \; + +# Copy vip files to base path +cp -r vip/* ./ + +# Delete uneeded vip folder +rm -rf vip + +# Push to deploy +git config user.name "GitHub Actions" +git config user.email "github-actions-bot@users.noreply.github.com" + +git add --all +git commit -m "Build: $COMMIT_BRANCH [ci skip]" +git remote set-url origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} +git push -f origin $COMMIT_BRANCH + +echo "Deployed Successfully!" + +exit 0 \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..716123fb7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,16 @@ +on: + push: + branches: + - master + - develop + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: ./.github/actions/deploy + env: + APP_ID: ${{ secrets.APP_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ github.ref }} From a1bc7dcaf797a4623a6119226e780bf693522120 Mon Sep 17 00:00:00 2001 From: "Jonathan (JB) Belcher" Date: Thu, 16 Apr 2020 11:39:46 -0400 Subject: [PATCH 2/4] Just deploy Develop for now --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 716123fb7..ae10ba516 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,7 +1,6 @@ on: push: branches: - - master - develop jobs: From 5c3b55af728d254525ebb5fdab681b734a336819 Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Sat, 18 Apr 2020 09:38:33 -0400 Subject: [PATCH 3/4] Fix spelling in comment --- .github/actions/deploy/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh index f519f9ba5..bd6bb7774 100755 --- a/.github/actions/deploy/entrypoint.sh +++ b/.github/actions/deploy/entrypoint.sh @@ -49,7 +49,7 @@ find . -maxdepth 1 ! -name '.git' ! -name 'dist' ! -name 'vip' -exec rm -rf {} \ # Copy vip files to base path cp -r vip/* ./ -# Delete uneeded vip folder +# Delete unneeded vip folder rm -rf vip # Push to deploy From 431e7739a4af491ace9c0d8a502c325781767e0e Mon Sep 17 00:00:00 2001 From: "Jonathan (JB) Belcher" Date: Mon, 27 Apr 2020 12:44:32 -0400 Subject: [PATCH 4/4] Use existing deploy script --- .github/actions/deploy/entrypoint.sh | 63 +--------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh index bd6bb7774..309e725eb 100755 --- a/.github/actions/deploy/entrypoint.sh +++ b/.github/actions/deploy/entrypoint.sh @@ -1,66 +1,5 @@ #!/bin/sh -l -COMMIT_BRANCH='' -WEB_APP_URL='' -APP_ENGINE_URL='' - -case $BRANCH in - - "refs/heads/develop") - COMMIT_BRANCH='webapp-develop' - WEB_APP_URL='https://simplenote-develop.go-vip.net' - APP_ENGINE_URL='https://develop.simplenote.com' - ;; - - "refs/heads/master") - COMMIT_BRANCH='webapp' - WEB_APP_URL='https://simplenote.go-vip.co' - APP_ENGINE_URL='https://app.simplenote.com' - ;; - - *) - exit 0 - ;; -esac - -# Install Node Modules -npm install - -#Setup config-local to override config -json_string=$(printf '{"app_id": "%s", "app_key": "12345", "development": false, "wpcc_client_id": "0", "wpcc_redirect_url": "https://simplenote.com", "is_app_engine": true, "web_app_url": "%s", "app_engine_url": "%s"}' "$APP_ID" "$WEB_APP_URL" "$APP_ENGINE_URL") -echo "$json_string" > config-local.json - -# Build site -NODE_ENV=production make build - -# Variables -ORIGIN_URL=$(git config --get remote.origin.url) - -# Checkout deploy branch -if [ "$(git branch | grep $COMMIT_BRANCH)" ] -then - git branch -D $COMMIT_BRANCH -fi -git checkout -b $COMMIT_BRANCH - -# Delete files not needed in production -find . -maxdepth 1 ! -name '.git' ! -name 'dist' ! -name 'vip' -exec rm -rf {} \; - -# Copy vip files to base path -cp -r vip/* ./ - -# Delete unneeded vip folder -rm -rf vip - -# Push to deploy -git config user.name "GitHub Actions" -git config user.email "github-actions-bot@users.noreply.github.com" - -git add --all -git commit -m "Build: $COMMIT_BRANCH [ci skip]" -git remote set-url origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} -git push -f origin $COMMIT_BRANCH - -echo "Deployed Successfully!" +npm run deploy $BRANCH exit 0 \ No newline at end of file