Rewrite CI logic with metadata-action and build-push-action
This commit is contained in:
parent
246dd0bc11
commit
d0347549a4
@ -7,6 +7,8 @@ on:
|
|||||||
branches: master
|
branches: master
|
||||||
push:
|
push:
|
||||||
branches: master
|
branches: master
|
||||||
|
release:
|
||||||
|
types: [published, edited]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
hadolint:
|
hadolint:
|
||||||
@ -18,7 +20,7 @@ jobs:
|
|||||||
uses: hadolint/hadolint-action@v1.5.0
|
uses: hadolint/hadolint-action@v1.5.0
|
||||||
with:
|
with:
|
||||||
ignore: DL3018
|
ignore: DL3018
|
||||||
buildx:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -31,18 +33,29 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Print builder available platforms
|
name: Print builder available platforms
|
||||||
run: echo ${{ steps.buildx.outputs.platforms }}
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||||
|
-
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: serjs/go-socks5-proxy
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{raw}}
|
||||||
-
|
-
|
||||||
name: Dockerhub login
|
name: Dockerhub login
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Run Buildx for amd64, armv7, arm64 architectures
|
name: Run Buildx for amd64, armv7, arm64 architectures
|
||||||
run: |
|
uses: docker/build-push-action@v2
|
||||||
docker buildx build \
|
with:
|
||||||
--platform linux/amd64,linux/arm/v7,linux/arm64 \
|
context: .
|
||||||
--output "type=image,push=false" \
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
--push \
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
--tag "$DOCKERHUB_REPOSITORY:latest" \
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
.
|
labels: ${{ steps.meta.outputs.labels }}
|
38
.github/workflows/release.yml
vendored
38
.github/workflows/release.yml
vendored
@ -1,38 +0,0 @@
|
|||||||
name: "Release tag"
|
|
||||||
env:
|
|
||||||
DOCKERHUB_REPOSITORY: serjs/go-socks5-proxy
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
# Only use the types keyword to narrow down the activity types that will trigger your workflow.
|
|
||||||
types: [published, edited]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
buildx:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
id: buildx
|
|
||||||
uses: crazy-max/ghaction-docker-buildx@v1.1.0
|
|
||||||
-
|
|
||||||
name: Release version
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
|
|
||||||
-
|
|
||||||
name: Print release version
|
|
||||||
run: echo ${{ env.RELEASE_VERSION }}
|
|
||||||
-
|
|
||||||
name: Dockerhub login
|
|
||||||
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
-
|
|
||||||
name: Run Buildx for amd64, armv7, arm64 architectures
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm/v7,linux/arm64 \
|
|
||||||
--output "type=image,push=false" \
|
|
||||||
--push \
|
|
||||||
--tag "$DOCKERHUB_REPOSITORY:$RELEASE_VERSION" \
|
|
||||||
.
|
|
Loading…
Reference in New Issue
Block a user