From 66bab3d8059fde868b59d1aeb9e0bdecb6c0d55e Mon Sep 17 00:00:00 2001 From: seepine Date: Thu, 27 Apr 2023 11:32:28 +0800 Subject: [PATCH] ci(actions): add build docker image workflow (#118) ### Add secret ``` DOCKERHUB_TOKEN=xxx ``` ### Tag when tag like `v1.0.0`, it will build multi platform docker image `gitea/act_runner:1.0.0` and `gitea/act_runner:latest`, then push to docker hub ### Use > volume `/data` save `.runner` config file > volume `/root/.cache` save actcache and actions cache ```sh docker run -e GITEA_INSTANCE_URL=*** \ -e GITEA_RUNNER_REGISTRATION_TOKEN=*** \ -e GITEA_RUNNER_NAME=*** \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /root/act_runner/data:/data \ -v /root/act_runner/cache:/root/.cache \ gitea/act_runner ``` Test join runners success ![image](/attachments/f5287e93-e27c-420f-a3d5-8f9b54bfdbb6) Test run action success ![image](/attachments/7235af17-f598-4fc8-88b4-d4771b1f07cd) Co-authored-by: Jason Song Reviewed-on: https://gitea.com/gitea/act_runner/pulls/118 Reviewed-by: Jason Song Co-authored-by: seepine Co-committed-by: seepine --- .gitea/workflows/build-image.yml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .gitea/workflows/build-image.yml diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml new file mode 100644 index 0000000..5dfc522 --- /dev/null +++ b/.gitea/workflows/build-image.yml @@ -0,0 +1,46 @@ +name: Build image +on: + push: + tags: + - v* +jobs: + build-image: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + env: + DOCKER_USERNAME: gitea + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Get Meta + id: meta + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(echo ${{ github.ref }} | awk -F"/" '{print $3}' | awk -F"v" '{print $2}') >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: | + ${{ env.DOCKER_USERNAME }}/${{ steps.meta.outputs.REPO_NAME }}:latest + ${{ env.DOCKER_USERNAME }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}