[buildbot] Introduce GitHub actions

LEDE Commits lede-commits at lists.infradead.org
Sun May 14 02:40:19 PDT 2023


ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/0590107ff4e23f85d00e6b9d391841e6574db413

commit 0590107ff4e23f85d00e6b9d391841e6574db413
Author: Petr Štetiar <ynezz at true.cz>
AuthorDate: Sun May 14 09:12:44 2023 +0200

    Introduce GitHub actions
    
    Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 .github/workflows/build-push.yml | 88 ++++++++++++++++++++++++++++++++++++++++
 .gitignore                       |  2 +
 2 files changed, 90 insertions(+)

diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml
new file mode 100644
index 0000000..61a1c1b
--- /dev/null
+++ b/.github/workflows/build-push.yml
@@ -0,0 +1,88 @@
+name: Build and push containers
+on:
+  push:
+    branches:
+      - master
+    tags:
+      - 'v*'
+  pull_request:
+
+env:
+  BUILDBOT_VERSION: 3.5.0
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+  build-test-push:
+    name: Build, test and push containers
+    runs-on: ubuntu-latest
+
+    permissions:
+      packages: write
+
+    strategy:
+      fail-fast: ${{ github.event_name == 'pull_request' }}
+      matrix:
+        container_flavor:
+          - master
+          - worker
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout at v3
+
+      - name: Environment variables
+        run: |
+          echo "GIT_SHA_SHORT=${GITHUB_SHA::8}" >> $GITHUB_ENV
+
+      - name: Build container and export it to local Docker
+        uses: docker/build-push-action at v4
+        with:
+          load: true
+          tags: local/${{ matrix.container_flavor }}
+          file: docker/build${{ matrix.container_flavor }}/Dockerfile
+          build-args: |
+            BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
+            OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}
+
+      - name: Test master Docker container
+        if: matrix.container_flavor == 'master'
+        run: |
+          docker run --detach --name test-master local/master
+          sleep 5
+          docker logs test-master | tee master.log
+          grep "buildmaster configured in /master" master.log
+
+      - name: Test worker Docker container
+        if: matrix.container_flavor == 'worker'
+        run: |
+          docker run --detach --env BUILDWORKER_NAME=X --env BUILDWORKER_PASSWORD=Y --name test-worker local/worker
+          sleep 5
+          docker logs test-worker | tee worker.log
+          grep "worker configured in /builder" worker.log
+
+      - name: Docker meta
+        id: meta
+        uses: docker/metadata-action at v4
+        with:
+          images: name=ghcr.io/${{ github.actor }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
+
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action at v2
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Build container again and push it
+        uses: docker/build-push-action at v4
+        with:
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}
+          labels: ${{ steps.meta.outputs.labels }}
+          file: docker/build${{ matrix.container_flavor }}/Dockerfile
+          build-args: |
+            BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
+            OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}
diff --git a/.gitignore b/.gitignore
index 5dca1da..3a2e179 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@ phase[12]/twistd.*
 !.gitlab
 !.gitlab/*
 !.gitlab/**/*
+!.github
+!.github/**/*




More information about the lede-commits mailing list