mirror of
https://github.com/lddsb/drone-dingtalk-message.git
synced 2026-06-13 18:51:40 +08:00
56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: Publish to DockerHub and Github Package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
dockerhub:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Repo metadata
|
|
id: repo
|
|
uses: actions/github-script@v3
|
|
with:
|
|
script: |
|
|
const repo = await github.repos.get(context.repo)
|
|
return repo.data
|
|
- name: Prepare
|
|
id: prep
|
|
run: |
|
|
DOCKER_IMAGE=lddsb/drone-dingtalk-message
|
|
GITHUB_IMAGE=ghcr.io/lddsb/drone-dingtalk-message
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
MINOR=${VERSION%.*}
|
|
MAJOR=${MINOR%.*}
|
|
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
|
|
TAGS="$TAGS,${GITHUB_IMAGE}:${VERSION},${GITHUB_IMAGE}:${MINOR},${GITHUB_IMAGE}:${MAJOR},${GITHUB_IMAGE}:latest"
|
|
fi
|
|
echo ::set-output name=tags::${TAGS}
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Login to GitHub Container Register
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.CR_PAT }}
|
|
- name: Build and push
|
|
id: docker_build
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ steps.prep.outputs.tags }}
|