feat: Automatically build and push docker image #32
Workflow file for this run
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
on: [push] | |
jobs: | |
Tests: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./server-tests | |
env: | |
DEBUG: "*" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- working-directory: ./server-nodejs | |
run: cp conf_template.json conf.json | |
- working-directory: ./server-nodejs | |
run: npm ci | |
- working-directory: ./server-nodejs | |
run: npm start & #Would be better to directory run tests with mocha + supertest | |
#instead of running the server in background | |
- run: npm ci | |
- run: npm test | |
services: | |
mongo: | |
image: mvertes/alpine-mongo:latest | |
ports: | |
- 27017:27017 | |
push_image: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ github.repository }} | |
- uses: docker/build-push-action@v5 | |
with: | |
file: docker/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |