From 890ccdecbf491b1855ca8f7d7bf00103a98044f2 Mon Sep 17 00:00:00 2001 From: james-choncholas Date: Sat, 6 Apr 2024 02:53:04 +0000 Subject: [PATCH] Update self-hosted CD --- .github/workflows/devcontainer.yml | 81 +++++++++++------------------- .github/workflows/docker-image.yml | 59 ++++++++++------------ 2 files changed, 54 insertions(+), 86 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 77e4da5..b68f9dc 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -7,62 +7,37 @@ on: branches: [ "master" ] env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: build: - runs-on: [self-hosted, linux, x64] + runs-on: [snail-runners] steps: - - name: Copy Runner Env to Workflow Env - run: | - echo "::add-mask::${LOCAL_REG_URL}" - echo "::add-mask::${LOCAL_REG_USER}" - echo "::add-mask::${LOCAL_REG_PASS}" - echo "LOCAL_REG_URL=${LOCAL_REG_URL}" >> $GITHUB_ENV - echo "LOCAL_REG_USER=${LOCAL_REG_USER}" >> $GITHUB_ENV - echo "LOCAL_REG_PASS=${LOCAL_REG_PASS}" >> $GITHUB_ENV - - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - token: ${{ secrets.SUBMODULE_PAT }} - - - uses: actions/setup-node@v4 - with: - node-version: 'latest' - - - name: Docker Login to Local Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.LOCAL_REG_URL }} - username: ${{ env.LOCAL_REG_USER }} - password: ${{ env.LOCAL_REG_PASS }} - - - name: Install updated Skopeo - # This can be omitted once runner images have a version of Skopeo > 1.4.1 - # See https://github.com/containers/skopeo/issues/1874 - run: | - # sudo apt purge buildah golang-github-containers-common podman skopeo - # sudo apt autoremove --purge - REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable" - source /etc/os-release - sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" - sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key - sudo apt-key add Release.key - sudo apt-get update - sudo apt-get install skopeo - - - name: Configure CMake in Cached devcontainer - uses: devcontainers/ci@v0.3 - env: - BUILDX_NO_DEFAULT_ATTESTATIONS: true - with: - imageName: ${{ env.LOCAL_REG_URL }}/secret-snail/localization-server-devcontainer - cacheFrom: ${{ env.LOCAL_REG_URL }}/secret-snail/localization-server-devcontainer - push: always - runCmd: | - cmake -B ./build -S ./ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && \ - cd ./build && make -j8 && ctest - + - name: Login to local container registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.LOCAL_REG_URL }} + username: ${{ secrets.LOCAL_REG_USER }} + password: ${{ secrets.LOCAL_REG_PASS }} + + - name: Install git + run: sudo apt-get update && sudo apt-get install -y git + + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - uses: actions/setup-node@v4 + with: + node-version: 'latest' + + - name: Build and test in devcontainer + uses: devcontainers/ci@v0.3 + env: + BUILDX_NO_DEFAULT_ATTESTATIONS: true + with: + imageName: ${{ secrets.LOCAL_REG_URL }}/secret-snail/localization-server-devcontainer + runCmd: | + cmake -B ./build -S ./ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} && \ + cd ./build && make -j8 && ctest diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index eb4d7ee..bf3b3ad 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,38 +7,31 @@ on: branches: [ "master" ] jobs: - build: - runs-on: [self-hosted, linux, x64] - steps: - - name: Copy Runner Env to Workflow Env - run: | - echo "::add-mask::${LOCAL_REG_URL}" - echo "::add-mask::${LOCAL_REG_USER}" - echo "::add-mask::${LOCAL_REG_PASS}" - echo "LOCAL_REG_URL=${LOCAL_REG_URL}" >> $GITHUB_ENV - echo "LOCAL_REG_USER=${LOCAL_REG_USER}" >> $GITHUB_ENV - echo "LOCAL_REG_PASS=${LOCAL_REG_PASS}" >> $GITHUB_ENV - - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - token: ${{ secrets.SUBMODULE_PAT }} - - - name: Docker Login to Local Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.LOCAL_REG_URL }} - username: ${{ env.LOCAL_REG_USER }} - password: ${{ env.LOCAL_REG_PASS }} + runs-on: [snail-runners] - - name: Build the Docker image - run: docker build . --file ./docker/Dockerfile --tag ${{ env.LOCAL_REG_URL }}/secret-snail/localization-server:latest - - - name: Run the tests in the container - run: | - docker run --rm ${{ env.LOCAL_REG_URL }}/secret-snail/localization-server:latest \ - bash -c "cd ./build && ctest" - - - name: Push the Docker image - run: docker push ${{ env.LOCAL_REG_URL }}/secret-snail/localization-server:latest + steps: + - name: Login to local container registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.LOCAL_REG_URL }} + username: ${{ secrets.LOCAL_REG_USER }} + password: ${{ secrets.LOCAL_REG_PASS }} + + - name: Install git + run: sudo apt-get update && sudo apt-get install -y git + + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Build the container + run: docker build . --file ./docker/Dockerfile --tag ${{ secrets.LOCAL_REG_URL }}/secret-snail/localization-server:latest + + - name: Run the tests in the container + run: | + docker run --rm ${{ secrets.LOCAL_REG_URL }}/secret-snail/localization-server:latest \ + bash -c "cd ./build && ctest" + + - name: Push the container + run: docker push ${{ secrets.LOCAL_REG_URL }}/secret-snail/localization-server:latest \ No newline at end of file