forked from fatedier/frp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add action to build and push image to dockerhub&github packages (fate…
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Build Image and Publish to Dockerhub & GPR | ||
|
||
on: | ||
push: | ||
branches: [ test-build ] | ||
release: | ||
types: [ created ] | ||
|
||
jobs: | ||
|
||
binary: | ||
name: Build Golang project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
- | ||
run: go version | ||
- | ||
name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
- | ||
name: Build | ||
run: make build | ||
- | ||
name: Archive artifacts for frpc | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: frpc | ||
path: bin/frpc | ||
- | ||
name: Archive artifacts for frps | ||
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 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
# download binaries of frpc and frps | ||
- | ||
name: Download binary of frpc | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: frpc | ||
path: bin/frpc | ||
- | ||
name: Download binary of frps | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: frps | ||
path: bin/frps | ||
# get release name | ||
- | ||
name: Get Release Name | ||
run: | | ||
echo ::set-env name=RELEASE_NAME::${GITHUB_REF#refs/*/} | ||
# prepare image tags | ||
- | ||
name: Prepare Image Tags | ||
run: | | ||
echo ::set-env name=DOCKERFILE_FRPC_PATH::dockerfiles/Dockerfile-for-frpc | ||
echo ::set-env name=DOCKERFILE_FRPS_PATH::dockerfiles/Dockerfile-for-frps | ||
echo ::set-env name=TAG_FRPC::fatedier/frpc:$RELEASE_NAME | ||
echo ::set-env name=TAG_FRPS::fatedier/frps:$RELEASE_NAME | ||
echo ::set-env name=TAG_FRPC_GPR::ghcr.io/${{ github.repository}}/frpc:$RELEASE_NAME | ||
echo ::set-env name=TAG_FRPS_GPR::ghcr.io/${{ github.repository}}/frps:$RELEASE_NAME | ||
# build images | ||
- | ||
name: Build Images | ||
run: | | ||
# for Docker hub | ||
docker build --file $DOCKERFILE_FRPC_PATH --tag $TAG_FRPC . | ||
docker build --file $DOCKERFILE_FRPS_PATH --tag $TAG_FRPS . | ||
# for GPR | ||
docker build --file $DOCKERFILE_FRPC_PATH --tag $TAG_FRPC_GPR . | ||
docker build --file $DOCKERFILE_FRPS_PATH --tag $TAG_FRPS_GPR . | ||
# push to dockerhub | ||
- | ||
name: Publish to Dockerhub | ||
run: | | ||
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
docker push $TAG_FRPC | ||
docker push $TAG_FRPC | ||
# push to gpr | ||
- | ||
name: Publish to GPR | ||
run: | | ||
echo ${{ secrets.GPR_TOKEN }} | docker login ghcr.io --username ${{ github.repository_owner }} --password-stdin | ||
docker push $TAG_FRPC_GPR | ||
docker push $TAG_FRPS_GPR |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:edge | ||
|
||
RUN apk add --update ca-certificates | ||
|
||
ADD bin/frpc /usr/bin | ||
|
||
ENTRYPOINT ["frpc"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:edge | ||
|
||
RUN apk add --update ca-certificates | ||
|
||
ADD bin/frps /usr/bin | ||
|
||
ENTRYPOINT ["frps"] |