add workflow

This commit is contained in:
Stanislaw
2022-12-26 01:20:29 +01:00
parent 92ece902f7
commit 6cb5f2659a
2 changed files with 27 additions and 0 deletions

22
.github/workflow/deploy.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: Deploy
on:
push:
branches: ["master"]
pull_request:
types: ["closed"]
branches: ["master"]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build -t ${{ github.repository }} .
- name: Deploy image
run: |
docker stop ${{ github.event.repository.name }} || true
docker rm ${{ github.event.repository.name }} || true
docker run ${{ github.event.repository.name }}
docker run -p 127.0.0.1:2021:2021 -e "DATABASE_URL=${{ secrets.DATABASE_URL }}" --network api --ip 172.0.0.5 -d --name ${{ github.event.repository.name }} ${{ github.repository }}

5
Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM golang:latest
WORKDIR /app
COPY ./ ./
RUN go get .
RUN go run .