Skip to content

docs: update

docs: update #76

Workflow file for this run

name: Build & Deploy
on:
workflow_dispatch:
push:
branches:
- master
paths-ignore: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths
- ".github/**"
jobs:
tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Deploy basic-postgres for tests if not exists
run: >-
(docker rm -f basic-postgres || true) &&
docker run -d --name basic-postgres --network runner
--restart always -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD
-it postgres:14.1-alpine
- name: Run tests
run: |
# bash -c 'while !</dev/tcp/basic-postgres/5432; do sleep 1; done'
sleep 20
PGPASSWORD=$POSTGRES_PASSWORD psql -h basic-postgres -U postgres -c "CREATE DATABASE docker;"
PGPASSWORD=$POSTGRES_PASSWORD psql -h basic-postgres -U postgres -f $PWD/db/init.sql
APP_DB_HOST=basic-postgres /usr/local/go/bin/go test -v $PWD/go
build:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set output
run: |
now=$(date +%Y-%m-%d-%H-%M-%S)
echo "IMAGE_VERSION_API=${{ secrets.DOCKERHUB_USERNAME }}/on3zcc_api:$now" >> $GITHUB_ENV
echo "IMAGE_VERSION_FRONT=${{ secrets.DOCKERHUB_USERNAME }}/on3zcc_front:$now" >> $GITHUB_ENV
echo "IMAGE_VERSION_DB=${{ secrets.DOCKERHUB_USERNAME }}/on3zcc_db:$now" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
run: |
docker-compose build
docker tag on3zcc_api ${{ env.IMAGE_VERSION_API }}
docker tag on3zcc_front ${{ env.IMAGE_VERSION_FRONT }}
docker tag on3zcc_db ${{ env.IMAGE_VERSION_DB }}
- name: Push API
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_VERSION_API }}
- name: Push Front
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_VERSION_FRONT }}
- name: Push DB
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_VERSION_DB }}
- name: Set artifact
run: |
echo ${{ env.IMAGE_VERSION_API }} > version_api.txt
echo ${{ env.IMAGE_VERSION_FRONT }} > version_front.txt
echo ${{ env.IMAGE_VERSION_DB }} > version_db.txt
- uses: actions/upload-artifact@v3
with:
name: image-version
path: version_api.txt
- uses: actions/upload-artifact@v3
with:
name: image-version
path: version_front.txt
- uses: actions/upload-artifact@v3
with:
name: image-version
path: version_db.txt
deploy:
needs: build
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Deploy
run: |
docker-compose build --no-cache
docker-compose up -d