Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub action to deploy the app to develop.simplenote.com #2002

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun fact, not the biggest deal here, but each of these lines creates a new "layer" in the Docker image and can carry a reasonable performance hit. since it's an automated build it won't matter too much but it's common to join these into one RUN statement. put differently, we've created these on separate RUN lines for organizational purposes but that creates an unintended side-effect in the Docker image we didn't want.

line-continuation marks and indentation are our friends, and now we can alphabetize the dependencies and make future diffs clearer

RUN dpkg --add-architecture i386 \
    && apt update \
    && apt -y install \
         g++-multilib \
         gcc-multilib \
         libx11-dev libx11-dev:i386 \
         libxkbfile-dev libxkbfile-dev:i386 \
         libxss-dev \
         make \
         python \
         rpm


COPY "entrypoint.sh" "/entrypoint.sh"
ENTRYPOINT ["/entrypoint.sh"]

CMD [""]
23 changes: 23 additions & 0 deletions .github/actions/deploy/deploy.yml
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs indicate that this is here to override the ENTRYPOINT in the Dockerfile. since we're creating the Dockerfile and not overwriting anything I don't understand why we need it, or why we need the entrypoint.sh file at all.

it seems like if it works then things could be kept simpler if we directly embedded the call to npm run deploy

if it's the case that we need this external script in order to pass the BRANCH argument then I think a couple things would help:

  • remove ENTRYPOINT from the Dockerfile
  • add an explanatory comment why we're taking several steps in what seems like it should only take one

the docs don't seem incredibly clear to me. it would be worth verifying if we have access to the ENV vars like BRANCH from inside the Dockerfile without external helpers.

RUN dpkg…

CMD ["sh", "-c", "npm run deploy $BRANCH"]

env:
APP_ID: ${{ inputs.APP_ID }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
BRANCH: ${{ inputs.BRANCH }}
5 changes: 5 additions & 0 deletions .github/actions/deploy/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -l

npm run deploy $BRANCH

exit 0
15 changes: 15 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
push:
branches:
- 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 }}