You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.2 KiB
59 lines
2.2 KiB
name: CI
|
|
|
|
# Controls when the action will run. Triggers the workflow on push to master or development
|
|
# with a tag like v1.0.0 or v1.0.0-dev
|
|
on:
|
|
push:
|
|
tags:
|
|
- v[0-9]+.[0-9]+.[0-9]+
|
|
- v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Get Version
|
|
id: get_version
|
|
uses: battila7/get-version-action@v2.0.0
|
|
|
|
- name: Install go-bindata and build migrations
|
|
env:
|
|
GOPATH: /home/runner/work/Geeksbot/
|
|
run: |
|
|
go get -u github.com/go-bindata/go-bindata/...
|
|
/home/runner/work/Geeksbot/bin/go-bindata -pkg migrations -prefix $GITHUB_WORKSPACE/internal/database/migrations/ -o $GITHUB_WORKSPACE/internal/database/migrations/bindata.go $GITHUB_WORKSPACE/internal/database/migrations/
|
|
head $GITHUB_WORKSPACE/internal/database/migrations/bindata.go
|
|
|
|
- name: Build container image
|
|
env:
|
|
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }}
|
|
run: docker build -t registry.digitalocean.com/djpianalto/geeksbot:$IMAGE_TAG .
|
|
|
|
- name: Install doctl
|
|
uses: digitalocean/action-doctl@v2
|
|
with:
|
|
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
|
|
|
|
- name: Login 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 registry.digitalocean.com/djpianalto/geeksbot
|
|
|
|
- name: Update deployment file
|
|
run: TAG=${{ steps.get_version.outputs.version-without-v }} && sed -i 's|<IMAGE>|registry.digitalocean.com/djpianalto/geeksbot:'${TAG}'|' $GITHUB_WORKSPACE/deployment.yml
|
|
|
|
- name: Save DigitalOcean kubeconfig with short-lived credentials
|
|
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 discord-bots
|
|
|
|
- name: Deploy to DigitalOcean Kubernetes
|
|
run: kubectl apply -f $GITHUB_WORKSPACE/deployment.yml
|
|
|
|
- name: Verify deployment
|
|
run: kubectl rollout status deployment/geeksbot
|