87 lines
3.1 KiB
YAML
87 lines
3.1 KiB
YAML
name: Appsmith Client Workflow
|
|
|
|
on:
|
|
push:
|
|
branches: [ release, master ]
|
|
# Only trigger if files have changed in this specific path
|
|
paths:
|
|
- 'app/client/**'
|
|
pull_request:
|
|
branches: [ release, master ]
|
|
paths:
|
|
- 'app/client/**'
|
|
# Change the working directory for all the jobs in this workflow
|
|
defaults:
|
|
run:
|
|
working-directory: app/client
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checkout the code
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Use Node.js 10.16.3
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: '10.16.3'
|
|
|
|
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v2
|
|
env:
|
|
cache-name: cache-yarn-dependencies
|
|
with:
|
|
# maven dependencies are stored in `~/.m2` on Linux/macOS
|
|
path: ~/.npm
|
|
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.OS }}-node-
|
|
${{ runner.OS }}-
|
|
|
|
# Install all the dependencies
|
|
- name: Install dependencies
|
|
run: yarn install
|
|
|
|
- name: Set the build environment based on the branch
|
|
id: vars
|
|
run: |
|
|
REACT_APP_ENVIRONMENT="DEVELOPMENT"
|
|
if [ ${GITHUB_REF} == '/refs/heads/master' ]; then
|
|
REACT_APP_ENVIRONMENT="PRODUCTION"
|
|
elif [ ${GITHUB_REF} == '/refs/heads/master' ]; then
|
|
REACT_APP_ENVIRONMENT="STAGING"
|
|
fi
|
|
echo ::set-output name=REACT_APP_ENVIRONMENT::${REACT_APP_ENVIRONMENT}
|
|
|
|
- name: Build the code for automation
|
|
run: |
|
|
REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} GIT_SHA=${GITHUB_SHA} yarn build
|
|
|
|
- name: Run the jest tests
|
|
run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn run test:unit
|
|
|
|
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
|
|
# first 11 characters. This can be used to build images for several branches
|
|
- name: Get the version to tag the Docker image
|
|
id: branch_name
|
|
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
|
|
|
|
# Build release Docker image and push to Docker Hub
|
|
- name: Push release image to Docker Hub
|
|
if: success() && github.ref == 'refs/heads/release'
|
|
run: |
|
|
docker build -t appsmith/appsmith-editor:${{steps.branch_name.outputs.tag}} .
|
|
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
|
docker push appsmith/appsmith-editor
|
|
|
|
# Build master Docker image and push to Docker Hub
|
|
- name: Push production image to Docker Hub with commit tag
|
|
if: success() && github.ref == 'refs/heads/master'
|
|
run: |
|
|
docker build -t appsmith/appsmith-editor:${GITHUB_SHA} .
|
|
docker build -t appsmith/appsmith-editor:latest .
|
|
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
|
docker push appsmith/appsmith-editor |