Skip to content

Commit

Permalink
Update self-hosted CD
Browse files Browse the repository at this point in the history
  • Loading branch information
james-choncholas committed Apr 6, 2024
1 parent 9e5604e commit 890ccde
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 86 deletions.
81 changes: 28 additions & 53 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
59 changes: 26 additions & 33 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 890ccde

Please sign in to comment.