Skip to content

Commit

Permalink
feat: add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
jetsung committed Nov 6, 2024
1 parent 62d5dd3 commit 4b85448
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
release:
types: [prereleased]
push:
branches:
- main
- v*
- dev*
paths:
- "Containerfile"
- ".github/workflows/release.yml"

jobs:
build-ghcr:
name: Build And Push to ghcr.io
runs-on: ubuntu-latest
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
IMAGE_REGISTRY: ghcr.io
ORG_NAME: idevsig
IMAGE: cfspeedtest
TAG: latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to ghcr.io
uses: docker/login-action@v2
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
registry: ${{ env.IMAGE_REGISTRY }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.ORG_NAME }}/${{ env.IMAGE }}:${{ env.TAG }}

build-docker:
name: Build And Push Docker Hub
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE: cfspeedtest
TAG: latest

steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE }}:${{ env.TAG }}
19 changes: 19 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:alpine AS builder

WORKDIR /app

RUN apk add git curl

RUN git clone https://github.com/XIU2/CloudflareSpeedTest.git; \
cd CloudflareSpeedTest; \
go build

FROM alpine:latest
LABEL maintainer="Jetsung Chan<[email protected]>"

WORKDIR /app

COPY --from=builder /app/CloudflareSpeedTest/CloudflareSpeedTest /usr/local/bin/CloudflareSpeedTest
COPY --from=builder /app/CloudflareSpeedTest/ip.txt /app/ip.txt

CMD [ "CloudflareSpeedTest" ]

0 comments on commit 4b85448

Please sign in to comment.