Skip to content

ci: add github token for setup-protoc@v3, or will got err: #6

ci: add github token for setup-protoc@v3, or will got err:

ci: add github token for setup-protoc@v3, or will got err: #6

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Bingo
on:
push:
tags:
- "v*"
branches:
- develop
- feature/ci
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Unit tests.
run: make cover
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: ./_output/coverage.out
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the version
id: get_version
run: |
VERSION=$(git describe --tags)
VERSION=${VERSION#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate pb files
run: make protoc
- name: Build by Docker Compose
run: bash ./scripts/docker/build.sh ${{ env.VERSION }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bingo
path: |
_output/*tar.gz
publish:
name: Deploy Staging
needs:
- test
- build
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the version
id: get_version
run: |
VERSION=$(git describe --tags)
VERSION=${VERSION#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
name: bingo
path: ./_output
- name: Display structure of downloaded files
run: |
ls -l
- name: Deploy
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
script: bash ./scripts/docker/deploy.sh ${{ env.VERSION }} ${{ secrets.REMOTE_USER }} ${{ secrets.REMOTE_HOST }} ${{ secrets.REMOTE_KEY }}
# - name: Deploy
# uses: appleboy/scp-action@v0.1.7
# with:
# host: ${{ secrets.REMOTE_HOST }}
# username: ${{ secrets.REMOTE_USER }}
# key: ${{ secrets.REMOTE_KEY }}
# source: "./*"
# target: "/tmp"
#
# - name: Run
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.REMOTE_HOST }}
# username: ${{ secrets.REMOTE_USER }}
# key: ${{ secrets.REMOTE_KEY }}
# script: |
# mkdir -p /opt/bingo
# cd /opt/bingo
#
# rsync -a /tmp/build/docker/* ./
# rsync -a /tmp/build/docker/.env.example ./
# if [ ! -f .env ]; then
# cp .env.example .env
# fi
# if [ ! -f config/bingo-apiserver.yaml ]; then
# cp config/bingo-apiserver.example.yaml config/bingo-apiserver.yaml
# fi
#
# # Update app version by .env
# sed -i 's/APP_VERSION=.*/APP_VERSION=${{ env.VERSION }}/g' .env
#
# docker load < /tmp/bingo-apiserver.tar.gz
# docker-compose up -d
#
# rm -rf /tmp/build
# rm /tmp/bingo-apiserver.tar.gz
# rm config/bingo-apiserver.example.yaml