mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Implement GitHub actions CI
This commit is contained in:
parent
e6f0d0948b
commit
239ad901dd
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
github: 'lus'
|
43
.github/workflows/docker.yml
vendored
Normal file
43
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
name: docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: define branch name
|
||||||
|
run: echo "BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
|
||||||
|
- name: define commit hash
|
||||||
|
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
- name: define staging tag
|
||||||
|
if: env.BRANCH == 'develop'
|
||||||
|
run: echo "TAG=staging" >> $GITHUB_ENV
|
||||||
|
- name: define latest tag
|
||||||
|
if: env.BRANCH == 'main'
|
||||||
|
run: echo "TAG=latest" >> $GITHUB_ENV
|
||||||
|
- name: set up qemu
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: set up buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: log in to ghcr
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: lus
|
||||||
|
password: ${{ secrets.CR_TOKEN }}
|
||||||
|
- name: build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: ghcr.io/lus/pasty:${{ env.TAG }}
|
||||||
|
build-args:
|
||||||
|
PASTY_VERSION=${{ env.BRANCH }}-${{ env.COMMIT_HASH }}
|
21
.github/workflows/general.yml
vendored
Normal file
21
.github/workflows/general.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: general
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: setup go environment
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.16
|
||||||
|
- name: download dependencies
|
||||||
|
run: |
|
||||||
|
go version
|
||||||
|
go mod download
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
go build ./cmd/pasty/
|
13
Dockerfile
13
Dockerfile
@ -1,15 +1,20 @@
|
|||||||
# Build the application
|
# Choose the golang image as the build base image
|
||||||
FROM golang:1.16-alpine AS build
|
FROM golang:1.16-alpine AS build
|
||||||
RUN apk update && apk upgrade && \
|
|
||||||
apk add --no-cache bash git openssh build-base
|
# Define the directory we should work in
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Download the necessary go modules
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
|
# Build the application
|
||||||
|
ARG PASTY_VERSION=unset-debug
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go build \
|
RUN go build \
|
||||||
-o pasty \
|
-o pasty \
|
||||||
-ldflags "\
|
-ldflags "\
|
||||||
-X github.com/lus/pasty/internal/static.Version=$(git rev-parse --abbrev-ref HEAD)-$(git describe --tags --abbrev=0)-$(git log --pretty=format:'%h' -n 1)" \
|
-X github.com/lus/pasty/internal/static.Version=$PASTY_VERSION" \
|
||||||
./cmd/pasty/main.go
|
./cmd/pasty/main.go
|
||||||
|
|
||||||
# Run the application in an empty alpine environment
|
# Run the application in an empty alpine environment
|
||||||
|
Loading…
Reference in New Issue
Block a user