mirror of
https://github.com/p4gefau1t/trojan-go.git
synced 2024-04-21 12:21:34 +00:00
Feat: use specific commit for Docker image (#298)
To avoid mismatching commit when re-running workflow builds
This commit is contained in:
@@ -12,9 +12,6 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
@@ -32,8 +29,10 @@ jobs:
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
|
||||
echo ::set-output name=ref::${GITHUB_REF#refs/tags/}
|
||||
else
|
||||
echo ::set-output name=version::snapshot
|
||||
echo ::set-output name=ref::${{ github.sha }}
|
||||
fi
|
||||
echo ::set-output name=docker_platforms::linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
echo ::set-output name=docker_image::${{ secrets.DOCKER_USERNAME }}/trojan-go
|
||||
@@ -44,6 +43,7 @@ jobs:
|
||||
--output "type=image,push=true" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \
|
||||
--build-arg REF=${ref} \
|
||||
--file Dockerfile .
|
||||
|
||||
test:
|
||||
|
||||
@@ -10,9 +10,6 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
@@ -30,12 +27,14 @@ jobs:
|
||||
run: |
|
||||
echo ::set-output name=docker_platforms::linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
echo ::set-output name=docker_image::${{ secrets.DOCKER_USERNAME }}/trojan-go
|
||||
echo ::set-output name=ref::${{ github.sha }}
|
||||
|
||||
- name: Build and push docker image
|
||||
run: |
|
||||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
||||
--output "type=image,push=true" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:nightly" \
|
||||
--build-arg REF=${ref} \
|
||||
--file Dockerfile .
|
||||
|
||||
test:
|
||||
|
||||
+10
-2
@@ -1,8 +1,16 @@
|
||||
FROM golang:alpine AS builder
|
||||
WORKDIR /
|
||||
ARG REF
|
||||
RUN apk add git make &&\
|
||||
git clone https://github.com/p4gefau1t/trojan-go.git &&\
|
||||
cd trojan-go &&\
|
||||
git clone https://github.com/p4gefau1t/trojan-go.git
|
||||
RUN if [[ -z "${REF}" ]]; then \
|
||||
echo "No specific commit provided, use the latest one." \
|
||||
;else \
|
||||
echo "Use commit ${REF}" &&\
|
||||
cd trojan-go &&\
|
||||
git checkout ${REF} \
|
||||
;fi
|
||||
RUN cd trojan-go &&\
|
||||
make &&\
|
||||
wget https://github.com/v2fly/domain-list-community/raw/release/dlc.dat -O build/geosite.dat &&\
|
||||
wget https://github.com/v2fly/geoip/raw/release/geoip.dat -O build/geoip.dat
|
||||
|
||||
Reference in New Issue
Block a user