Skip to content

Commit

Permalink
feat: Automatically build and push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
zankia authored and remyla committed Mar 27, 2024
1 parent a90d975 commit bd27426
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
on: [push]
jobs:
Tests:
tests:
name: Run Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server-tests
env:
DEBUG: "*"
DEBUG: '*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -15,7 +17,7 @@ jobs:
- working-directory: ./server-nodejs
run: npm ci
- working-directory: ./server-nodejs
run: npm start & #Would be better to directory run tests with mocha + supertest
run: npm start & #Would be better to directly run tests with mocha + supertest
#instead of running the server in background
- run: npm ci
- run: npm test
Expand All @@ -25,3 +27,27 @@ jobs:
image: mvertes/alpine-mongo:latest
ports:
- 27017:27017

push_image:
name: Push Docker image
runs-on: ubuntu-latest
if: github.ref_type == 'tag' ||
contains(fromJSON('["master", "testing", "experimental"]'), github.ref_name)
needs: tests
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 }}
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on:
release:
types: [published]
Expand Down

0 comments on commit bd27426

Please sign in to comment.