Roles frontend #15
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 workflow will build a Node project with NPM and then push its Docker image to DockerHub | |
name: CI/CD | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: '18.x' | |
- name: Test and build | |
run: | | |
docker run --env PROFILE=test -d -p 8080:8080 udlepssoftarch/mypets-geiade-api | |
while ! nc -z localhost 8080; do sleep 10; done | |
docker ps -a | |
npm ci | |
npm run lint | |
npx start-server-and-test start http-get://localhost:4200 'cypress run --record --key ${{ secrets.CYPRESS_KEY }}' | |
npm run build -- --configuration production | |
- name: Login to DockerHub | |
if: success() && github.ref == 'refs/heads/main' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to Docker Hub | |
if: success() && github.ref == 'refs/heads/main' | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
udlepssoftarch/mypets-geiade:${{ github.sha }} | |
udlepssoftarch/mypets-geiade:latest |