1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00
v2fly/.github/workflows/docker.yaml
2020-07-24 12:37:33 +08:00

71 lines
2.5 KiB
YAML

name: Release Docker Image
on:
push:
tags:
- v*
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set up Checkout
uses: actions/checkout@v2
- name: Install Buildx and QEMU
run: |
export DOCKER_BUILDKIT=1
docker build --platform=local -o . git://github.com/docker/buildx
mkdir -p ~/.docker/cli-plugins
mv buildx ~/.docker/cli-plugins/docker-buildx
docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
docker buildx create --use --name build --node build --driver-opt network=host
- name: Log in to Docker Hub
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Get image version
id: get_image_version
run: echo ::set-output name=version::${GITHUB_REF#refs/*/}
- name: Get image name
id: get_image_name
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: echo ::set-output name=name::$(echo $DOCKER_USERNAME | tr '[:upper:]' '[:lower:]')/v2fly-core
- name: Get image platform
env:
PLATFORM: linux/386,linux/amd64,linux/arm/v7,linux/arm64
id: get_image_platform
run: echo ::set-output name=platform::"$PLATFORM"
- name: Build and push Docker image (version)
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_IMAGE_NAME: ${{ steps.get_image_name.outputs.name }}
DOCKER_IMAGE_VERSION: ${{ steps.get_image_version.outputs.version }}
DOCKER_IMAGE_PLATFORM: ${{ steps.get_image_platform.outputs.platform }}
run: |
docker buildx build \
--platform "$DOCKER_IMAGE_PLATFORM" \
--output "type=image,push=true" \
--tag "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_VERSION" \
--file ./Dockerfile .
- name: Build and push Docker image (latest)
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_IMAGE_NAME: ${{ steps.get_image_name.outputs.name }}
DOCKER_IMAGE_PLATFORM: ${{ steps.get_image_platform.outputs.platform }}
run: |
docker buildx build \
--platform "$DOCKER_IMAGE_PLATFORM" \
--output "type=image,push=true" \
--tag "$DOCKER_IMAGE_NAME":latest \
--file ./Dockerfile .