Docker Publish #118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Publish | |
on: | |
workflow_run: | |
workflows: ["CI Build"] | |
types: | |
- completed | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download event type file | |
uses: actions/download-artifact@v4 | |
with: | |
name: event | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GH_TOKEN }} | |
path: ./ | |
- name: Download tag name file | |
if: ${{ env.EVENT == 'tag' }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: tag_name | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GH_TOKEN }} | |
path: ./ | |
- name: Download dingofs artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dingofs | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GH_TOKEN }} | |
path: ./ | |
- name: Config trigger event env | |
run: | | |
if [ -f event.txt ]; then | |
echo "EVENT=$(cat event.txt)" >> $GITHUB_ENV | |
fi | |
- name: Config push tag env | |
if: ${{ env.EVENT == 'tag' }} | |
run: | | |
if [ -f tag_name.txt ]; then | |
echo "TAG_NAME=$(cat tag_name.txt)" >> $GITHUB_ENV | |
fi | |
- name: Print env info | |
run: | | |
echo "trigger event type is ${{ env.EVENT }}" | |
if [ "${{ env.EVENT }}" == "pull_request" ]; then | |
echo "pull request haven't merged, not need to publish image." | |
exit 0 | |
fi | |
if [ -n "${{ env.TAG_NAME }}" ]; then | |
echo "tag name is ${{ env.TAG_NAME }}" | |
fi | |
- name: List directory contents after download | |
run: ls -la | |
- name: Extract artifact | |
run: tar -xzvf dingofs.tar.gz -C curvefs/docker/rocky9 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: dingodatabase/dingofs | |
tags: | | |
type=raw,enable=${{ env.EVENT == 'tag' }},value=${{ env.TAG_NAME }} | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=sha,prefix=,format=long | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./curvefs/docker/rocky9 | |
file: ./curvefs/docker/rocky9/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} |