Unverified Commit 10399351 authored by sparkcyf's avatar sparkcyf Committed by GitHub
Browse files

Create main.yml

parent ecf53a54
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
name: ci
on:
  workflow_dispatch: #github页面手动触发
  push:
    tags:
      - "v*.*"
env:
  IMAGE_NAME: bandersnatch-docker
jobs:
  get-tags:
    runs-on: ubuntu-20.04
    env:
      TZ: Asia/Shanghai
    outputs:
      tags: ${{ steps.set-output-id.outputs.tags }}
    steps:
      - uses: actions/checkout@v2
      - name: set-output
        id: set-output-id
        run: |
          VERSION=edge
          if [[ $GITHUB_REF == refs/tags/* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo ::set-output name=tags::${VERSION}          
  push-ghcr:
    runs-on: ubuntu-20.04
    env:
      TZ: Asia/Shanghai
      REGISTRY: ghcr.io
    steps:
      - uses: actions/checkout@v2
      - name: Login
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.PACKAGES_TOKEN }}
      - name: Build && Push
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: |
            ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ needs.get-tags.outputs.tags }}
            ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest