Skip to content

make swagger

make swagger #42

Workflow file for this run

name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
REGISTRY: "registry.digitalocean.com/sku4"
REPOSITORY: "repository"
CONTAINER_NAME: "alice"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout master
uses: actions/checkout@v3
- name: Build container image
run: docker build -t $(echo $REGISTRY)/$(echo $REPOSITORY):$(echo $CONTAINER_NAME)-$(echo $GITHUB_SHA | head -c7) .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 600
- name: Push image to DigitalOcean Container Registry
run: docker push $(echo $REGISTRY)/$(echo $REPOSITORY):$(echo $CONTAINER_NAME)-$(echo $GITHUB_SHA | head -c7)
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to Digital Ocean droplet via SSH action
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSHKEY }}
envs: REPOSITORY,REGISTRY,GITHUB_SHA,CONTAINER_NAME
script: |
# Login into Digital Ocean Registry
docker login -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} $(echo $REGISTRY)
# Pull container
docker pull $(echo $REGISTRY)/$(echo $REPOSITORY):$(echo $CONTAINER_NAME)-$(echo $GITHUB_SHA | head -c7)
# Stop running container
docker stop $(echo $CONTAINER_NAME)
# Remove old container
docker rm $(echo $CONTAINER_NAME)
# Rename container
docker image tag $(echo $REGISTRY)/$(echo $REPOSITORY):$(echo $CONTAINER_NAME)-$(echo $GITHUB_SHA | head -c7) $(echo $CONTAINER_NAME):latest
# Set env variables
# export TOKEN=${{ secrets.TOKEN }}
# Run a new container from a new image
docker run -d \
--restart always \
--publish 8001:8000 \
-v /home/skubach/alice-checklist/db:/root/db \
-v /home/skubach/alice-checklist/configs/googlekeep:/root/configs/googlekeep \
--name $(echo $CONTAINER_NAME) \
$(echo $CONTAINER_NAME):latest
# Clean unused images
docker image prune -af