1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-25 08:50:54 -05:00
sub2clash/.github/workflows/docker.yml

70 lines
1.9 KiB
YAML
Raw Normal View History

2023-09-13 03:26:56 -04:00
name: Build and Push to GHCR
on:
push:
2023-09-14 12:31:57 -04:00
branches:
- dev
tags:
- '*'
workflow_dispatch:
2023-09-13 03:26:56 -04:00
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set tag name
id: set_tag
run: |
if [[ $GITHUB_REF == refs/heads/* ]]; then
echo "::set-output name=tag::$(echo $GITHUB_REF | cut -d'/' -f3)"
else
echo "::set-output name=tag::${{ github.ref_name }}"
fi
- name: Check if triggered by tag
id: check_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "::set-output name=triggered_by_tag::true"
else
echo "::set-output name=triggered_by_tag::false"
fi
- name: Build and push Docker image for dev branch
if: steps.check_tag.outputs.triggered_by_tag == 'false'
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
build-args: |
dev=true
version=${{ github.sha }}
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }}
- name: Build and push Docker image for tags
if: steps.check_tag.outputs.triggered_by_tag == 'true'
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
build-args: |
dev=false
version=${{ steps.set_tag.outputs.tag }}
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }}
ghcr.io/${{ github.repository }}:latest
2023-09-13 03:26:56 -04:00