mirror of
https://github.com/unchainese/unchain.git
synced 2025-12-24 12:38:02 +08:00
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
name: Go
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
environment: production
|
|
env:
|
|
GIT_SHA: ${{ github.sha }}
|
|
GIT_REF_NAME: ${{ github.ref_name }}
|
|
GIT_REPO: ${{ github.repository }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: install ssh-scp
|
|
run: sudo apt-get install -y openssh-client
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Get build time
|
|
id: build-time
|
|
run: echo "buildTime=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
|
|
|
- name: Build
|
|
env:
|
|
CGO_ENABLED: '1'
|
|
GOARCH: 'amd64'
|
|
GIT_SHA: ${{ github.sha }}
|
|
GIT_REF_NAME: ${{ github.ref_name }}
|
|
GIT_REPO: ${{ github.repository }}
|
|
run: |
|
|
echo "Building Go application with gitHash=${{ env.gitHash }} and buildTime=${{ env.buildTime }}"
|
|
go build -ldflags="-X 'github.com/unchainese/unchain/internal/global.gitHash=${{ github.sha }}' -X 'github.com/unchainese/unchain/internal/global.buildTime=${{ env.buildTime }}'" -o unchain main.go
|
|
|
|
- name: Deploy to AWS EC2
|
|
env:
|
|
SSH_HOST: ${{ secrets.EC2_HOST }}
|
|
SSH_USER: ${{ secrets.EC2_USER }}
|
|
SSH_KEY: ${{ secrets.EC2_KEY }}
|
|
CONFIG_TOML: ${{ vars.CONFIG_TOML }}
|
|
run: bash .github/workflows/deploy.sh
|
|
|
|
|
|
# - name: Deploy to AliCould ECS
|
|
# env:
|
|
# SSH_HOST: ${{ secrets.ECS_HOST }}
|
|
# SSH_USER: ${{ secrets.ECS_USER }}
|
|
# SSH_KEY: ${{ secrets.ECS_KEY }}
|
|
# CONFIG_TOML: ${{ vars.CONFIG_TOML }}
|
|
# run: bash .github/workflows/deploy.sh
|
|
# add more server to deploy
|
|
|
|
|