seaweedfs-csi-driver/.github/workflows/release.yaml
2021-07-11 00:56:49 -07:00

106 lines
3.1 KiB
YAML

name: Build & release Docker images
on:
push:
branches:
- "**"
tags:
- 'v*'
paths:
- 'cmd/seaweedfs-csi-driver/Dockerfile'
- 'cmd/seaweedfs-csi-driver/*.go'
- 'pkg/driver/**'
- 'go.*'
- '.github/**'
# Build on PR
pull_request:
# Allow trigger for external PRs
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Get the current tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Annotate Docker images
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ github.repository }}
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./cmd/seaweedfs-csi-driver/Dockerfile
platforms: linux/amd64
push: false
labels: ${{ steps.docker_meta.outputs.labels }}
tags: ${{ github.repository }}:${{ env.RELEASE_VERSION }}
- name: Publish Docker image to DockerHub & GitHub Container Registry
uses: docker/build-push-action@v2
with:
context: .
file: ./cmd/seaweedfs-csi-driver/Dockerfile
platforms: linux/amd64
push: ${{ startsWith(github.ref, 'refs/tags/') }}
labels: ${{ steps.docker_meta.outputs.labels }}
tags: |
${{ github.repository }}:${{ env.RELEASE_VERSION }}
ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }}
- name: Update DockerHub repo description
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ github.repository }}
- name: Create Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.RELEASE_VERSION }}