1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-25 01:24:42 -05:00
sub2sing-box/.github/workflows/docker.yaml

67 lines
1.8 KiB
YAML
Raw Normal View History

2024-03-12 12:11:34 -04:00
name: Build and Push Docker
on:
push:
branches:
- dev
tags:
- "*"
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/sub2sing-box
ghcr.io/${{ github.repository }}
2024-03-12 14:02:17 -04:00
- name: Prepare args
2024-03-12 12:11:34 -04:00
id: prep
run: |
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
VERSION="${{ github.sha }}"
fi
if [[ "$GITHUB_REF" == 'refs/heads/dev' ]]; then
VERSION="${{ github.sha }}"
fi
if [[ "$GITHUB_REF" == 'refs/tags/'* ]]; then
VERSION=$TAG_NAME
fi
2024-03-12 14:02:17 -04:00
echo "version=$VERSION" >> $GITHUB_ENV
2024-03-12 12:11:34 -04:00
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image to GHCR and Docker Hub
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
2024-03-12 14:02:17 -04:00
build-args: version=${{ env.version }}
2024-03-12 12:11:34 -04:00
push: true
platforms: linux/amd64,linux/arm,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}