Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
shink committed Aug 30, 2024
1 parent e714cff commit 1383c84
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 14 deletions.
15 changes: 1 addition & 14 deletions .github/actions/clean-up/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Clean up space"
description: "Clean up disk space on GitHub Runner"
description: "Remove redundant files and packages when building Docker images"
runs:
using: 'composite'
steps:
Expand Down Expand Up @@ -120,17 +120,4 @@ runs:
run: |
echo "::group::Display disk space"
sudo df -h
sudo du -h -d 1 /usr | sort -hr
sudo du -h -d 1 /opt | sort -hr
sudo du -h -d 2 /home | sort -hr
sudo du -h -d 2 ~ | sort -hr
sudo du -h -d 1 /usr/bin | sort -hr
sudo du -h -d 1 /usr/lib | sort -hr
sudo du -h -d 1 /usr/local | sort -hr
sudo du -h -d 1 /usr/share | sort -hr
sudo du -h -d 1 /var/lib | sort -hr
sudo du -h -d 1 /var/cache | sort -hr
sudo du -h -d 1 /etc | sort -hr
echo "::endgroup::"
107 changes: 107 additions & 0 deletions .github/workflows/_docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,112 @@ jobs:
uses: actions/checkout@v4

- name: Clean up
if: ${{ inputs.clean-up }}
continue-on-error: true
uses: ./.github/actions/clean-up

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Not allowed to use secrets in `if` condition
- name: Check tokens
id: check-tokens
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
HW_USERNAME: ${{ secrets.HW_USERNAME }}
HW_TOKEN: ${{ secrets.HW_TOKEN }}
run: |
if [ -n "$DOCKERHUB_USERNAME" ] && [ -n "$DOCKERHUB_TOKEN" ]; then
echo "dockerhub=true" >> $GITHUB_OUTPUT
fi
if [ -n "$QUAY_USERNAME" ] && [ -n "$QUAY_TOKEN" ]; then
echo "quay=true" >> $GITHUB_OUTPUT
fi
if [ -n "$HW_USERNAME" ] && [ -n "$HW_TOKEN" ]; then
echo "hw=true" >> $GITHUB_OUTPUT
fi
- name: Login to Docker Hub
if: ${{ inputs.push && steps.check-tokens.outputs.dockerhub == 'true' }}
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container
if: ${{ inputs.push }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Login to RedHat Quay
if: ${{ inputs.push && steps.check-tokens.outputs.quay == 'true' }}
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Login to Huawei Cloud
if: ${{ inputs.push && steps.check-tokens.outputs.hw == 'true' && inputs.hw-registry }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.hw-registry }}
username: ${{ secrets.HW_USERNAME }}
password: ${{ secrets.HW_TOKEN }}

- name: Extract metadata for Docker
id: metadata
uses: docker/metadata-action@v5
with:
bake-target: "docker-metadata-action"

- name: Build and push Docker image
id: bake
uses: docker/bake-action@v5
with:
files: |
${{ github.workspace }}/docker-bake.hcl
${{ steps.metadata.outputs.bake-file-labels }}
${{ steps.metadata.outputs.bake-file-annotations }}
targets: ${{ matrix.target }}
push: ${{ inputs.push }}
set: ${{ inputs.set }}
provenance: false
sbom: false

- name: Export metadata
id: export
if: ${{ steps.bake.outputs.metadata }}
shell: bash
run: |
METADATA_FILE_NAME="${{ matrix.target }}-metadata.json"
echo "metadata-file-name=${METADATA_FILE_NAME}" >> $GITHUB_OUTPUT
echo '${{ steps.bake.outputs.metadata }}' > /tmp/${METADATA_FILE_NAME}
- name: Upload metadata
id: upload-artifact
if: ${{ inputs.upload-metadata }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.export.outputs.metadata-file-name }}
path: /tmp/${{ steps.export.outputs.metadata-file-name }}
if-no-files-found: error
retention-days: 7

- name: Display available disk space
if: ${{ always() }}
shell: bash
run: |
set -x
sudo df -h
docker images -a
48 changes: 48 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,51 @@ jobs:
QUAY_OWNER: ${{ secrets.QUAY_OWNER }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

cann:
name: cann
needs:
- python
uses: ./.github/workflows/_docker-build.yml
with:
target: 'cann'
push: ${{ github.event_name != 'pull_request' }}
secrets:
DOCKERHUB_OWNER: ${{ secrets.DOCKERHUB_OWNER }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_OWNER: ${{ secrets.QUAY_OWNER }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

pytorch:
name: pytorch
needs:
- cann
uses: ./.github/workflows/_docker-build.yml
with:
target: 'pytorch'
push: ${{ github.event_name != 'pull_request' }}
secrets:
DOCKERHUB_OWNER: ${{ secrets.DOCKERHUB_OWNER }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_OWNER: ${{ secrets.QUAY_OWNER }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

mindspore:
name: mindspore
needs:
- cann
uses: ./.github/workflows/_docker-build.yml
with:
target: 'mindspore'
push: ${{ github.event_name != 'pull_request' }}
secrets:
DOCKERHUB_OWNER: ${{ secrets.DOCKERHUB_OWNER }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_OWNER: ${{ secrets.QUAY_OWNER }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

0 comments on commit 1383c84

Please sign in to comment.