fix(infra): fix github actions #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
- development | |
pull_request: | |
branches: | |
- '*' | |
env: | |
CI: true | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: development | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
working-directory: frontend | |
run: npm ci | |
- name: Build | |
working-directory: frontend | |
run: npm run build | |
- name: Install dependencies | |
working-directory: backend | |
run: go get ./... | |
- name: Build | |
working-directory: backend | |
run: go build -o build/kubevoyage ./cmd/kubevoyage | |
#- name: Test with the Go CLI | |
# run: go test | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: production-artifacts | |
path: | | |
backend/ | |
frontend/public | |
build-docker: | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ github.ref }} != 'master' && ${{ github.ref }} != 'development' | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: production-artifacts | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/kubevoyage:${{ env.BRANCH_NAME }} | |
release: | |
needs: build-docker | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
if: ${{ github.ref }} == 'master' || ${{ github.ref }} == 'development' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm install -g semantic-release @saithodev/semantic-release-backmerge @semantic-release/github @semantic-release/exec | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
run: npx semantic-release --debug |