Skip to content

Instantly share code, notes, and snippets.

@wey-gu
Last active December 1, 2022 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wey-gu/c57a2f6eb4d3eaab9208feda42fa8b48 to your computer and use it in GitHub Desktop.
Save wey-gu/c57a2f6eb4d3eaab9208feda42fa8b48 to your computer and use it in GitHub Desktop.
github actions to push dual arch docker images

Add gh action:

name: release

on:
  release:
    types:
      - published

jobs:
  package:
  docker:
    name: build docker image
    runs-on: ubuntu-latest
    steps:
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      #comment out login
      #- name: Log into registry
      #  uses: docker/login-action@v2
      #  with:
      #    username: ${{ secrets.DOCKER_USERNAME }}
      #    password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Build and push Docker images
        uses: docker/build-push-action@v3
        with:
          platforms: linux/amd64,linux/arm64
          tags: vesoft/nebula-console/nightly, vesoft/nebula-console/v3-nightly
        #comment out push
        #push: true

Test it locally:

curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash

./bin/act -l

result should be like:

$ ./bin/act -l
Stage  Job ID   Job name                           Workflow name  Workflow file     Events
0      sync     auto label                         Auto label     check_label.yml   issues
0      docker   build docker image                 docker         docker.yml        push
0      package  build package                      package        package.yml       push
0      lint     lint                               build          pull_request.yml  pull_request
0      docker   build docker image                 release        release.yml       release
0      package  package and upload release assets  release        release.yml       release
1      build    build                              build          pull_request.yml  pull_request
echo DOCKER_USERNAME=foo > .env
echo DOCKER_PASSWORD=bar >> .env
echo GITHUB_TOKEN=xxx >> .env

./bin/act -j docker -v -w ./.github/workflows/docker.yml --secret-file .env --bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment