Unverified Commit 9106dcf4 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

CI/CD - Push images in GitHub Action (#202)

Push Docker images in GitHub Action.
parent 890ce65d
...@@ -4,16 +4,23 @@ on: ...@@ -4,16 +4,23 @@ on:
push: push:
branches: branches:
- main - main
- release/*
pull_request: pull_request:
branches: branches:
- main - main
- release/* - release/*
release:
types:
- published
workflow_dispatch: workflow_dispatch:
jobs: jobs:
docker: docker:
name: Docker build ${{ matrix.name }} name: Docker build ${{ matrix.name }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy: strategy:
matrix: matrix:
include: include:
...@@ -21,8 +28,8 @@ jobs: ...@@ -21,8 +28,8 @@ jobs:
tags: superbench/main:cuda11.1.1,superbench/superbench:latest tags: superbench/main:cuda11.1.1,superbench/superbench:latest
- name: rocm4.2-pytorch1.7.0 - name: rocm4.2-pytorch1.7.0
tags: superbench/main:rocm4.2-pytorch1.7.0 tags: superbench/main:rocm4.2-pytorch1.7.0
# - name: rocm4.0-pytorch1.7.0 - name: rocm4.0-pytorch1.7.0
# tags: superbench/main:rocm4.0-pytorch1.7.0 tags: superbench/main:rocm4.0-pytorch1.7.0
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
...@@ -36,11 +43,24 @@ jobs: ...@@ -36,11 +43,24 @@ jobs:
done done
sudo apt-get clean sudo apt-get clean
df -h df -h
echo 'nproc: '$(nproc)
- name: Prepare metadata - name: Prepare metadata
id: metadata id: metadata
run: | run: |
TAGS=${{ matrix.tags }} TAGS=${{ matrix.tags }}
if [ "${{ github.event_name }}" == "push" ] && [[ ${{ github.ref }} == refs/heads/release/* ]]; then
TAGS=$(sed "s/main:/release:${GITHUB_REF##*/}-/g" <<< ${TAGS})
fi
if [ "${{ github.event_name }}" == "pull_request" ] && [[ ${{ github.base_ref }} == release/* ]]; then
TAGS=$(sed "s/main:/release:${GITHUB_BASE_REF##*/}-/g" <<< ${TAGS})
fi
if [ "${{ github.event_name }}" == "release" ]; then
TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS})
GHCR_TAG=$(cut -d, -f1 <<< ${TAGS} | sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g")
TAGS="${TAGS},${GHCR_TAG}"
fi
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS})
fi
DOCKERFILE=dockerfile/${{ matrix.name }}.dockerfile DOCKERFILE=dockerfile/${{ matrix.name }}.dockerfile
CACHE_FROM="type=registry,ref=$(cut -d, -f1 <<< ${TAGS})" CACHE_FROM="type=registry,ref=$(cut -d, -f1 <<< ${TAGS})"
...@@ -53,6 +73,8 @@ jobs: ...@@ -53,6 +73,8 @@ jobs:
echo ::set-output name=tags::${TAGS} echo ::set-output name=tags::${TAGS}
echo ::set-output name=cache_from::${CACHE_FROM} echo ::set-output name=cache_from::${CACHE_FROM}
echo ::set-output name=cache_to::${CACHE_TO} echo ::set-output name=cache_to::${CACHE_TO}
- name: Echo image tag
run: echo ${{ steps.metadata.outputs.tags }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
...@@ -63,6 +85,13 @@ jobs: ...@@ -63,6 +85,13 @@ jobs:
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to the GitHub Container Registry
uses: docker/login-action@v1
if: ${{ github.event_name == 'release' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
......
...@@ -88,7 +88,7 @@ ENV PATH="${PATH}" \ ...@@ -88,7 +88,7 @@ ENV PATH="${PATH}" \
WORKDIR ${SB_HOME} WORKDIR ${SB_HOME}
ADD third_party third_party ADD third_party third_party
RUN ROCM_VERSION=rocm-4.0.0 make -j -C third_party rocm RUN ROCM_VERSION=rocm-4.0.0 make -j -C third_party -o rocm_rocblas rocm
# Workaround for image having package installed in user path # Workaround for image having package installed in user path
RUN mv /root/.local/bin/* /opt/conda/bin/ && \ RUN mv /root/.local/bin/* /opt/conda/bin/ && \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment