Docker Build Images (AMD64) #151
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Build Images (AMD64) | |
env: | |
# Also remember to change the 'docker/build.sh' script | |
IMAGE_VER: "v2" | |
on: | |
schedule: | |
# Once every Wednesday at 00:00 | |
- cron: '0 0 * * 3' | |
push: | |
branches: | |
- master | |
paths: | |
- 'docker/**' | |
- '.github/workflows/vcpkg_docker_amd64.yml' | |
pull_request: | |
paths: | |
- 'docker/**' | |
- '.github/workflows/vcpkg_docker_amd64.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
# arch is to tag docker images for uniqueness | |
host: | |
- { name: 'ubuntu-22.04', arch: '' } | |
container: | |
- { version: '22.04', codename: 'jammy' } | |
runs-on: ${{ matrix.host.name }} | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Cleanup working directory with container root | |
run: | | |
docker run --rm -v $(pwd):/workspace -w /workspace ubuntu:latest find . -name . -o -prune -exec rm -rf -- {} + || true | |
- uses: actions/checkout@v4 | |
- name: Generate Image Name | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
run: | | |
test_name="" | |
if [[ "${GITHUB_REF}" != "refs/heads/master" ]] ; then | |
test_name="test-${BRANCH_NAME////_}-" | |
fi | |
echo "IMAGE_NAME=ghcr.io/lifting-bits/cxx-common/${test_name}vcpkg-builder-ubuntu-${{ env.IMAGE_VER }}:${{ matrix.container.version }}${{ matrix.host.arch }}" >> ${GITHUB_ENV} | |
- name: Build image | |
working-directory: docker | |
run: | | |
# Pull freshest ubuntu Docker image | |
docker pull ubuntu:${{ matrix.container.version}} | |
docker build -f Dockerfile.ubuntu.vcpkg \ | |
--no-cache \ | |
--target caching \ | |
--build-arg "DISTRO_VERSION=${{ matrix.container.codename }}" \ | |
-t "${IMAGE_NAME}" \ | |
. | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image | |
run: docker push "${IMAGE_NAME}" |