-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: migration from Travis CI to GitHub Actions #149
- Loading branch information
1 parent
89008a9
commit 40e9f51
Showing
4 changed files
with
86 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
source env.sh | ||
|
||
check_code() | ||
{ | ||
if [[ $1 -ne $2 ]]; then | ||
echo "$3 has failed [error: $1]" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# | ||
# Build the app | ||
# | ||
echo "##[group]Build" | ||
|
||
cd $APP | ||
yarn pwa:build | ||
EXIT_CODE=$? | ||
check_code $EXIT_CODE 0 "Builing the client" | ||
|
||
# Log in to docker before building the app because of rate limiting | ||
docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD" | ||
check_code $? 0 "Connecting to Docker" | ||
|
||
# Create an archive to speed docker build process | ||
cd ../.. | ||
tar --exclude='$APP/test' -zcf $GITHUB_WORKSPACE/kalisio.tgz kalisio | ||
|
||
# Build the image | ||
cd $GITHUB_WORKSPACE | ||
docker build --build-arg APP=$APP --build-arg FLAVOR=$FLAVOR --build-arg BUILD_NUMBER=$GITHUB_RUN_NUMBER -f dockerfile -t kalisio/$APP:$TAG . | ||
check_code $? 0 "Building the app docker image" | ||
|
||
echo "##[endgroup]" | ||
|
||
# | ||
# Deploy the app | ||
# | ||
echo "##[group]Deploy" | ||
|
||
# Push the app image to the hub with the version tag | ||
docker push kalisio/$APP:$TAG | ||
check_code $? 0 "Pushing the $APP:$TAG docker image" | ||
|
||
# Push the app image to the hub with the flavor tag | ||
docker tag kalisio/$APP:$TAG kalisio/$APP:$FLAVOR | ||
docker push kalisio/$APP:$FLAVOR | ||
check_code $? 0 "Pushing the $APP:$TAG docker image" | ||
|
||
echo "##[endgroup]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,29 +2,43 @@ name: Build & Deploy | |
on: [push] | ||
|
||
jobs: | ||
app: | ||
test: | ||
if: ${{ github.event.head_commit.message !~ /\[skip[ _-]test\]/ }} | ||
runs-on: ubuntu-latest | ||
env: | ||
DB_URL: "mongodb://mongo:27017" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ secrets.NODE_VERSION }} | ||
- name: Start MongoDB | ||
uses: timgchile/[email protected] | ||
with: | ||
mongodb-version: 4.0 | ||
- name: Run tests | ||
run: | | ||
chmod +x ./.github/workflows/test.sh | ||
./.github/workflows/test.sh | ||
build: | ||
if: ${{ github.event.head_commit.message !~ /(skip[ _-]app)/ }} | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_USER: ${{ secrets.DOCKER_USER }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
TOKEN_GITHUB: ${{ secrets.TOKEN_GITHUB }} | ||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ secrets.NODE_VERSION }} | ||
- name: Build & deploy | ||
run: | | ||
if [[ $COMMIT_MESSAGE !~ /(skip[ _-]app)/ ]]; then | ||
chmod +x ./.github/workflows/app.sh | ||
./.github/workflows/app.sh | ||
fi | ||
chmod +x ./.github/workflows/build.sh | ||
./.github/workflows/build.sh | ||
doc: | ||
if: ${{ contains(github.event.head_commit.message, '[build doc]')}} | ||
if: ${{ github.event.head_commit.message =~ /\[skip[ _-]test\]/ }} | ||
runs-on: ubuntu-latest | ||
env: | ||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
|
@@ -42,7 +56,7 @@ jobs: | |
name: Notify on slack | ||
runs-on: ubuntu-latest | ||
if: ${{ always() }} | ||
needs: [app, doc] | ||
needs: [test, build, doc] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Notify on slack | ||
|
@@ -51,6 +65,6 @@ jobs: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_APPS }} | ||
SLACK_USERNAME: GitHub Actions | ||
SLACK_ICON: https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png | ||
SLACK_COLOR: ${{ (needs.app.reult == 'failed' || needs.doc.reult == 'failed') && 'danger' || 'good' }} | ||
SLACK_MESSAGE: Build of ${{ github.repository }}@${{ github.ref_name }} by ${{ github.actor }} ${{ (needs.app.reult == 'failed' || needs.doc.reult == 'failed') && 'failed' || 'passed' }} | ||
SLACK_COLOR: ${{ (needs.test.result == 'failed' || needs.build.result == 'failed' || needs.doc.result == 'failed') && 'danger' || 'good' }} | ||
SLACK_MESSAGE: Build of ${{ github.repository }}@${{ github.ref_name }} by ${{ github.actor }} ${{ (needs.test.result == 'failed' || needs.build.result == 'failed' || needs.doc.result == 'failed') && 'failed' || 'passed' }} | ||
SLACK_FOOTER: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
echo "Running tests" | ||
|
||
source env.sh | ||
|
||
# Run backend tests | ||
cd api | ||
yarn test |