docker push #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "The tag version you want to build" | |
push: | |
paths: | |
- "v2ray.sh" | |
- "Dockerfile" | |
- ".github/workflows/docker-push.yml" | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- "v2ray.sh" | |
- "Dockerfile" | |
- ".github/workflows/docker-push.yml" | |
name: docker push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get tag to build | |
id: tag | |
run: | | |
latest_tag=$(curl -sSL --retry 5 "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" | jq .tag_name | awk -F '"' '{print $2}') | |
if [[ -z "${{ github.event.inputs.tag }}" ]]; then | |
echo "Use the latest release tag of v2ray-core: ${latest_tag}" | |
echo "tag=${latest_tag}" >> $GITHUB_OUTPUT | |
else | |
echo "Use tag: ${{ github.event.inputs.tag }}" | |
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | |
fi | |
- name: Determine whether to push to DockerHub | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "PUSH=true" >> $GITHUB_ENV | |
- name: Prepare environment variables | |
id: prepare | |
run: | | |
echo "docker_platforms=linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64" >> $GITHUB_OUTPUT | |
echo "docker_image=v2fly/v2fly-core" >> $GITHUB_OUTPUT | |
echo "docker_tag=${{ steps.tag.outputs.tag }}" >> $GITHUB_OUTPUT | |
echo "docker_is_push=${PUSH:-false}" >> $GITHUB_OUTPUT | |
- name: Build tag & latest release | |
run: | | |
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \ | |
--output "type=image,push=${{ steps.prepare.outputs.docker_is_push }}" \ | |
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.docker_tag }}" \ | |
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \ | |
--build-arg TAG=${{ steps.prepare.outputs.docker_tag }} \ | |
--file Dockerfile . |