github.com/matrixorigin/matrixone@v0.7.0/.github/workflows/docker_ci.yml (about)

     1  name:  Build and Push images
     2  
     3  on:
     4    schedule:
     5      - cron: '0 22 * * *'
     6    release:
     7      types:
     8        - published
     9    workflow_dispatch:
    10  
    11  permissions:
    12    id-token: write
    13    contents: read
    14  
    15  jobs:
    16    dockerhub:
    17      runs-on: ubuntu-latest
    18  
    19      steps:
    20        - name: Checkout
    21          uses: actions/checkout@v3
    22  
    23        - name: Prepare
    24          id: prep
    25          run: |
    26            DOCKER_IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${GITHUB_REPOSITORY#*/}
    27            VERSION=nightly-${GITHUB_SHA::8}
    28            # If this is git tag, use the tag name as a docker tag
    29            if [[ $GITHUB_REF == refs/tags/* ]]; then
    30              VERSION=${GITHUB_REF#refs/tags/v}
    31            fi
    32            TAGS="${DOCKER_IMAGE}:${VERSION}"
    33            # If the VERSION looks like a version number, assume that
    34            # this is the most recent version of the image and also
    35            # tag it 'latest'.
    36            if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
    37              TAGS="$TAGS,${DOCKER_IMAGE}:latest"
    38            fi
    39            # Set output parameters.
    40            echo "tags=${TAGS}" >> $GITHUB_OUTPUT
    41            echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
    42  
    43        - name: Get image info
    44          run: |
    45            echo image-tags: ${{ steps.prep.outputs.tags }}
    46  
    47        - name: Set up QEMU
    48          uses: docker/setup-qemu-action@master
    49          with:
    50            image: tonistiigi/binfmt:latest
    51            platforms:  linux/amd64,linux/arm64
    52  
    53        - name: Set up Docker Buildx
    54          id: buildx
    55          uses:  docker/setup-buildx-action@v2
    56  
    57        - name: Login to DockerHub
    58          if: github.event_name != 'pull_request'
    59          uses: docker/login-action@v2
    60          with:
    61            username: ${{ secrets.DOCKERHUB_USERNAME }}
    62            password: ${{ secrets.DOCKERHUB_TOKEN }}
    63  
    64        - name: Build
    65          uses: docker/build-push-action@v3
    66          with:
    67            builder: ${{ steps.buildx.outputs.name }}
    68            context: .
    69            file: ./optools/images/Dockerfile
    70            platforms: linux/amd64,linux/arm64
    71            push: true
    72            tags: ${{ steps.prep.outputs.tags }}
    73  
    74    ecr:
    75      runs-on: ubuntu-latest
    76  
    77      steps:
    78        - name: Checkout
    79          uses: actions/checkout@v2
    80  
    81        - name: Prepare
    82          id: prep
    83          run: |
    84            DOCKER_IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${GITHUB_REPOSITORY#*/}
    85            VERSION=nightly-${GITHUB_SHA::8}
    86            # If this is git tag, use the tag name as a docker tag
    87            if [[ $GITHUB_REF == refs/tags/* ]]; then
    88              VERSION=${GITHUB_REF#refs/tags/v}
    89            fi
    90            # Set output parameters.
    91            echo "version=${VERSION}" >> $GITHUB_OUTPUT
    92  
    93        - name: Get image info
    94          run: |
    95            echo image-tags: ${{ steps.prep.outputs.version }}
    96  
    97        # push image to ecr
    98        - uses: ./.github/actions/ecr
    99          with:
   100            role: ${{ secrets.AWS_ROLE }}
   101            tag:  ${{ steps.prep.outputs.version }}