2020-09-23 11:05:50 +08:00
|
|
|
name: Build Image and Publish to Dockerhub & GPR
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [ created ]
|
2020-09-23 14:20:46 +08:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
tag:
|
|
|
|
description: 'Image tag'
|
|
|
|
required: true
|
|
|
|
default: 'test'
|
2020-09-23 11:05:50 +08:00
|
|
|
jobs:
|
|
|
|
binary:
|
|
|
|
name: Build Golang project
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Set up Go 1.x
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-06-03 00:56:07 +08:00
|
|
|
go-version: 1.16
|
|
|
|
|
|
|
|
- run: |
|
|
|
|
# https://github.com/actions/setup-go/issues/107
|
|
|
|
cp -f `which go` /usr/bin/go
|
|
|
|
|
|
|
|
- run: go version
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/checkout@v2
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Build
|
2020-09-23 11:05:50 +08:00
|
|
|
run: make build
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Archive artifacts for frpc
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: frpc
|
|
|
|
path: bin/frpc
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Archive artifacts for frps
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: frps
|
|
|
|
path: bin/frps
|
|
|
|
|
|
|
|
image:
|
|
|
|
name: Build Image from Dockerfile and binaries
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: binary
|
|
|
|
steps:
|
|
|
|
# environment
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Checkout
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: '0'
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 11:05:50 +08:00
|
|
|
# download binaries of frpc and frps
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Download binary of frpc
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: frpc
|
|
|
|
path: bin/frpc
|
2021-06-03 00:56:07 +08:00
|
|
|
|
|
|
|
- name: Download binary of frps
|
2020-09-23 11:05:50 +08:00
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: frps
|
|
|
|
path: bin/frps
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 14:20:46 +08:00
|
|
|
# get image tag name
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Get Image Tag Name
|
2020-09-23 11:05:50 +08:00
|
|
|
run: |
|
2020-09-23 14:40:22 +08:00
|
|
|
if [ x${{ github.event.inputs.tag }} == x"" ]; then
|
2020-11-09 16:56:53 +08:00
|
|
|
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
2020-09-23 14:20:46 +08:00
|
|
|
else
|
2020-11-09 16:56:53 +08:00
|
|
|
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
2020-09-23 14:20:46 +08:00
|
|
|
fi
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 11:05:50 +08:00
|
|
|
# prepare image tags
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Prepare Image Tags
|
2020-09-23 11:05:50 +08:00
|
|
|
run: |
|
2020-11-09 16:56:53 +08:00
|
|
|
echo "DOCKERFILE_FRPC_PATH=dockerfiles/Dockerfile-for-frpc" >> $GITHUB_ENV
|
|
|
|
echo "DOCKERFILE_FRPS_PATH=dockerfiles/Dockerfile-for-frps" >> $GITHUB_ENV
|
|
|
|
echo "TAG_FRPC=fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
|
|
|
echo "TAG_FRPS=fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
|
|
|
echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
|
|
|
echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 11:05:50 +08:00
|
|
|
# build images
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Build Images
|
2020-09-23 11:05:50 +08:00
|
|
|
run: |
|
|
|
|
# for Docker hub
|
2020-11-09 16:56:53 +08:00
|
|
|
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC }} .
|
|
|
|
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS }} .
|
2020-09-23 11:05:50 +08:00
|
|
|
# for GPR
|
2020-11-09 16:56:53 +08:00
|
|
|
docker build --file ${{ env.DOCKERFILE_FRPC_PATH }} --tag ${{ env.TAG_FRPC_GPR }} .
|
|
|
|
docker build --file ${{ env.DOCKERFILE_FRPS_PATH }} --tag ${{ env.TAG_FRPS_GPR }} .
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 11:05:50 +08:00
|
|
|
# push to dockerhub
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Publish to Dockerhub
|
2020-09-23 11:05:50 +08:00
|
|
|
run: |
|
|
|
|
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
2020-11-09 16:56:53 +08:00
|
|
|
docker push ${{ env.TAG_FRPC }}
|
|
|
|
docker push ${{ env.TAG_FRPS }}
|
2021-06-03 00:56:07 +08:00
|
|
|
|
2020-09-23 11:05:50 +08:00
|
|
|
# push to gpr
|
2021-06-03 00:56:07 +08:00
|
|
|
- name: Publish to GPR
|
2020-09-23 11:05:50 +08:00
|
|
|
run: |
|
|
|
|
echo ${{ secrets.GPR_TOKEN }} | docker login ghcr.io --username ${{ github.repository_owner }} --password-stdin
|
2020-11-09 16:56:53 +08:00
|
|
|
docker push ${{ env.TAG_FRPC_GPR }}
|
|
|
|
docker push ${{ env.TAG_FRPS_GPR }}
|