Docker build and push #130
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 build and push | |
on: | |
workflow_run: | |
workflows: ["Cross compile"] | |
branches: [main] | |
types: | |
- completed | |
jobs: | |
docker-build-push: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Log in to the GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
workflow: ${{ github.event.workflow_run.workflow_id }} | |
workflow_conclusion: success | |
check_artifacts: true | |
path: artifact | |
- name: Rearrange artifacts | |
run: | | |
# 如果该目录存在,则移动其下文件 | |
if [ -d "artifact/linux-amd64-artifact/linux/amd64" ]; then | |
mkdir -p artifact/linux/amd64 | |
mv artifact/linux-amd64-artifact/linux/amd64/* artifact/linux/amd64/ | |
fi | |
if [ -d "artifact/linux-arm64-artifact/linux/arm64" ]; then | |
mkdir -p artifact/linux/arm64 | |
mv artifact/linux-arm64-artifact/linux/arm64/* artifact/linux/arm64/ | |
fi | |
# 清理不再需要的空目录 | |
rm -rf artifact/linux-amd64-artifact | |
rm -rf artifact/linux-arm64-artifact | |
- name: Build Docker Image And Push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/cantoblanco/boringbay |