name: atlantis-base on: push: paths: - 'docker-base/Dockerfile.*' - '.github/workflows/atlantis-base.yml' branches: - "main" pull_request: paths: - 'docker-base/Dockerfile.*' - '.github/workflows/atlantis-base.yml' workflow_dispatch: defaults: run: working-directory: docker-base concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: build: strategy: matrix: image_type: [alpine, debian] runs-on: ubuntu-22.04 env: DOCKERFILE: "Dockerfile.${{ matrix.image_type }}" IMAGE_BASE: ghcr.io/${{ github.repository_owner }}/atlantis-base IMAGE_SUFFIX: ${{ matrix.image_type != 'alpine' && format('-{0}', matrix.image_type) || '' }} steps: - uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: image: tonistiigi/binfmt:latest platforms: arm64,arm - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to Packages Container registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Populate release version run: echo "RELEASE_VERSION=$(date +"%Y.%m.%d")" >> $GITHUB_ENV - name: Build and push atlantis-base:${{ env.RELEASE_VERSION }}${{ env.IMAGE_SUFFIX }} image uses: docker/build-push-action@v3 with: cache-from: type=gha cache-to: type=gha,mode=max context: docker-base build-args: ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type }} file: docker-base/${{ env.DOCKERFILE }} platforms: linux/arm64/v8,linux/amd64,linux/arm/v7 push: ${{ github.event_name != 'pull_request' }} # release version is the YYYYMMDD date of the build i.e. 20301210 # release version also has the image type appended i.e. 20301210-alpine # release tag is latest i.e. latest # release tag also has the image type appended i.e. latest-alpine # if it's Dec 10, 2030 and alpine, it will do 20301210, 20301210-alpine, latest, latest-alpine # if it's Dec 10, 2030 and debian, it will do 20301210-debian, latest-debian tags: | ${{ env.IMAGE_BASE }}:${{ env.RELEASE_VERSION }}${{ env.IMAGE_SUFFIX }} ${{ env.IMAGE_BASE }}:${{ env.RELEASE_VERSION }}-${{ matrix.image_type }} ${{ env.IMAGE_BASE }}:latest${{ env.IMAGE_SUFFIX }} ${{ env.IMAGE_BASE }}:latest-${{ matrix.image_type }}