diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..37708a1 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} \ No newline at end of file diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..3ca9e85 --- /dev/null +++ b/Containerfile @@ -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" + +WORKDIR /app + +COPY --from=builder /app/CloudflareSpeedTest/CloudflareSpeedTest /usr/local/bin/CloudflareSpeedTest +COPY --from=builder /app/CloudflareSpeedTest/ip.txt /app/ip.txt + +CMD [ "CloudflareSpeedTest" ] \ No newline at end of file