self hosted docker builds

This commit is contained in:
realbigsean 2023-08-09 16:15:51 -04:00
parent fddd4e4c87
commit 8d81f1bee7
No known key found for this signature in database
GPG Key ID: BE1B3DB104F6C788

View File

@ -14,6 +14,8 @@ env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
IMAGE_NAME: ${{ github.repository_owner}}/lighthouse IMAGE_NAME: ${{ github.repository_owner}}/lighthouse
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli
# Enable self-hosted runners for the sigp repo only.
SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/lighthouse' }}
jobs: jobs:
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX # Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
@ -50,7 +52,8 @@ jobs:
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }} VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
build-docker-single-arch: build-docker-single-arch:
name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }} name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }}
runs-on: ubuntu-22.04 # Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "large"]') || 'ubuntu-22.04' }}
strategy: strategy:
matrix: matrix:
binary: [aarch64, binary: [aarch64,
@ -74,24 +77,25 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Update Rust - name: Update Rust
if: env.SELF_HOSTED_RUNNERS == false
run: rustup update stable run: rustup update stable
- name: Dockerhub login - name: Dockerhub login
run: | run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Cross build Lighthouse binary - name: Cross build Lighthouse binary
if: env.SELF_HOSTED_RUNNERS == false
run: | run: |
cargo install cross cargo install cross
env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }} env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }}
- name: Make bin dir
if: env.SELF_HOSTED_RUNNERS == false
run: mkdir ./bin
- name: Move cross-built binary into Docker scope (if ARM) - name: Move cross-built binary into Docker scope (if ARM)
if: startsWith(matrix.binary, 'aarch64') if: startsWith(matrix.binary, 'aarch64')
run: | run: mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
mkdir ./bin;
mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
- name: Move cross-built binary into Docker scope (if x86_64) - name: Move cross-built binary into Docker scope (if x86_64)
if: startsWith(matrix.binary, 'x86_64') if: startsWith(matrix.binary, 'x86_64')
run: | run: mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
mkdir ./bin;
mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
- name: Map aarch64 to arm64 short arch - name: Map aarch64 to arm64 short arch
if: startsWith(matrix.binary, 'aarch64') if: startsWith(matrix.binary, 'aarch64')
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV