Skip to content

Commit

Permalink
devops: github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
VaalaCat committed Jan 19, 2024
1 parent 634f7e3 commit 2749d45
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 13 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -23,14 +23,47 @@ jobs:
# 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@v3

- uses: actions/checkout@v4
# Runs a set of commands using the runners shell
- name: npm setup
uses: actions/[email protected]
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Go
uses: actions/setup-go@v4
with:
node-version: 17
go-version: "1.21.x"
- name: npm install and build
run: |
npm install
npm run build
- name: Install dependencies
run: |
go mod tidy
- name: Compile server
run: bash ./build.sh
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: server-binary
# path: dist
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: "latest"
files: |
dist/*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
platforms: linux/amd64,linux/arm64
tags: VaalaCat/movie-sync:latest
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM alpine

COPY movie-sync-server-linux-amd64 /app/bin/movie-sync-server-linux-amd64
FROM node:20 AS frontend
WORKDIR /app
COPY . .
RUN npm install && npm run build

COPY dist /app/asset
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
COPY --from=frontend /app/out /app/out
RUN go build -o movie-sync-server

WORKDIR /app/bin

CMD [ "/app/bin/movie-sync-server-linux-amd64" ]
FROM alpine
COPY --from=builder /app/movie-sync-server /app/
WORKDIR /app
CMD ["/app/movie-sync-server"]

0 comments on commit 2749d45

Please sign in to comment.