Skip to content

Commit

Permalink
Convert pipeline to GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
micromaomao committed Dec 30, 2023
1 parent c7f0b1d commit 7b34eaa
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build docker image
on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Export variables
run: echo "IMAGE_TAG=ghcr.io/micromaomao/schsrch" >> $GITHUB_ENV
- name: Build script
run: >
git clean -dfx &&
chmod u=rwX,go=rX . -R &&
docker build . -t $IMAGE_TAG --no-cache &&
docker-compose -f docker-compose-example.yml up -d es mongo &&
sleep 40 &&
docker run --entrypoint=bash --user=www -t --network schsrch_mw -e NODE_ENV=development -e MONGODB=mongodb://mw-mongo/schsrch -e ES=mw-es:9200 -e SITE_ORIGIN=http://localhost -v $(pwd)/.git:/usr/src/app/.git $IMAGE_TAG -c "npm install coveralls && npm install istanbul && test/prepareDatabase.sh && npm run coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js";
if [ $? -ne 0 ]; then
exit 1;
fi;
docker run --entrypoint=bash -t --network schsrch_mw -p 3000:80 -e NODE_ENV=production -e MONGODB=mongodb://mw-mongo/schsrch -e ES=mw-es:9200 -e SITE_ORIGIN=http://localhost $IMAGE_TAG -c "node server.js" &
sleep 10 &&
curl -vI 'http://127.0.0.1:3000'
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push
run: >
docker push $IMAGE_TAG
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ RUN chown -R node:node /usr/src/app && \
setcap 'cap_net_bind_service=ep' /usr/local/bin/node
USER node:node

COPY --chown=node:node ./package.json .
RUN npm i --progress=false --loglevel=warn 2>&1
COPY --chown=node:node . .
RUN npm i --progress=false --loglevel=warn 2>&1
RUN npm ci
EXPOSE 80 443
STOPSIGNAL SIGTERM
HEALTHCHECK --timeout=2s CMD curl -f https://localhost/
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

![demo video](readme_video.gif)

[![Build Status](https://travis-ci.org/micromaomao/schsrch.svg?branch=master)](https://travis-ci.org/micromaomao/schsrch)
[![Coverage Status](https://coveralls.io/repos/github/micromaomao/schsrch/badge.svg?branch=dev)](https://coveralls.io/github/micromaomao/schsrch?branch=dev)
[![Dependencies](https://david-dm.org/micromaomao/schsrch.svg)](https://david-dm.org/micromaomao/schsrch)
[![devDependencies Status](https://david-dm.org/micromaomao/schsrch/dev-status.svg)](https://david-dm.org/micromaomao/schsrch?type=dev)
[![Known Vulnerabilities](https://snyk.io/test/github/micromaomao/schsrch/badge.svg)](https://snyk.io/test/github/micromaomao/schsrch)
Expand All @@ -13,7 +11,7 @@

## Ready-to-run docker image

[![](https://images.microbadger.com/badges/image/maowtm/schsrch.svg) maowtm/schsrch](https://hub.docker.com/r/maowtm/schsrch/)
[![](https://images.microbadger.com/badges/image/ghcr.io/micromaomao/schsrch.svg) ghcr.io/micromaomao/schsrch](ghcr.io/micromaomao/schsrch)

Environment variables needed: (i.e. docker run -e xxx=xxx -e… maowtm/schsrch)

Expand Down

0 comments on commit 7b34eaa

Please sign in to comment.