Topic/cd workflow (#66)

* scaffold cd dispatch

* fix bug

update

update

update

* repo -> runtime_args

* remove travis

* only run on commits to develop
This commit is contained in:
Lachlan Kermode
2021-01-19 22:07:10 +01:00
committed by GitHub
parent ca104e4abe
commit d6d565a0fc
6 changed files with 39 additions and 94 deletions

19
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: CD
on:
push:
branches: [ develop ]
# pull_request:
# branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Trigger CD build
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.CI_DISPATCH_TOKEN }}
repository: forensic-architecture/configs
event-type: remote-build
client-payload: '{"runtime_args": "datasheet", "branch": "${GITHUB_REF##*/}"}'

20
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
- run: npm install
- run: npm test
- run: npm run lint

View File

@@ -1,31 +0,0 @@
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the develop branch
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
- run: npm install
- run: npm test
- run: npm run lint

View File

@@ -1,14 +0,0 @@
language: node_js
node_js:
- stable
cache:
directories:
- node_modules
before_script:
- npm install -g yarn
install:
- yarn
script:
- yarn build
- yarn lint
- yarn test

View File

@@ -1,11 +0,0 @@
#!/bin/bash
ENCRYPT_MESSAGE="\nThe .env.enc file has not changed its contents from the version on origin/develop.\nTo ensure that tests pass in Travis, you need to encrypt the contents of .env before pushing to the remote, so that the Travis server can use your service account credentials.\nEnsure that the Travis CLI is installed on your local, run\n\n\tnpm run travis-encrypt\n\nand then push to the remote again.\nIf you don't care whether your build passes on Travis, you can run:\n\n\tgit push --no-verify\n\nand bypass this check.\n\n"
# check whether .env.enc has changed
if [ -z "`git diff origin/develop -- .env.enc`" ]; then
echo $ENCRYPT_MESSAGE
exit 1
fi

View File

@@ -1,38 +0,0 @@
#!/bin/bash
echo "Encrypting .env file for Travis..."
# confirm that the user has the core repo as origin, and is therefore a maintainer
# if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then
# echo "Travis encryption not required for satellite contributors, continuing.."
# exit 0
# fi
# confirm travis is installed
if [ ! hash travis 2>/dev/null ]; then
echo "============================================================================================"
echo "ERROR: Travis CLI is not installed on your local. Please install from:"
echo "\thttps://github.com/travis-ci/travis.rb"
echo "After installing, make sure that you login with:"
echo "\ttravis login --pro"
echo "============================================================================================"
exit 3
fi
# confirm there is a .env file to encrypt
if [ ! -f .env ]; then
echo "============================================================================================"
echo "ERROR: You must create a .env file and add your credentials. See .env.example for an example"
echo "============================================================================================"
exit 3
fi
# regex to match and delete 'before_install' and everything after it
# necessary to delete these lines to get Travis to build for multiple accounts
echo "creating new .travis.yml configuration"
sed -i.old '/^before_install.*/,$ d' .travis.yml
echo "old config file saved as .travis.yml.old"
travis encrypt-file .env --add --force --org
git add .env.enc
git add .travis.yml
echo ".env.enc created and added to commit"