ci: fix and update CI/CD pipelines for packer #17
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
name: Unit Tests | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [master] | |
jobs: | |
unittest: | |
runs-on: ubuntu-latest | |
environment: ${{ vars.ENVIRONMENT }} | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres:latest | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: ${{ vars.DATABASE }} | |
POSTGRES_USER: ${{ vars.DBUSER }} | |
POSTGRES_PASSWORD: ${{ secrets.DBPASSWORD }} | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
name: Run unit tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: "Create .env file" | |
run: | | |
touch .env | |
echo ENVIRONMENT=${{ vars.ENVIRONMENT }} >> .env | |
echo HOSTNAME=${{ vars.HOSTNAME}} >> .env | |
echo PORT=${{ vars.PORT }} >> .env | |
echo DATABASE=${{ vars.DATABASE }} >> .env | |
echo DBUSER=${{ vars.DBUSER }} >> .env | |
echo DBPASSWORD=${{ secrets.DBPASSWORD }} >> .env | |
- name: Clean Install Dependencies | |
run: npm ci | |
- name: Run test scripts | |
run: npm run test | |
# Github token to run public workflows | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |