Skip to content

Release: build and publish starter images #11

Release: build and publish starter images

Release: build and publish starter images #11

# Copyright (C) 2022 Dynamic Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'Release: build and publish starter images'
on:
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
prepare-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Configure Git and Maven settings
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
mkdir -p ~/.ssh
printf '%s\n' "${{ secrets.SSH_SECRET_KEY }}" > ~/.ssh/id_rsa
chmod 0600 ~/.ssh/id_rsa
- name: Prepare release and push tag
run: ./mvnw --batch-mode release:prepare -P release
build-and-push-images:
runs-on: ubuntu-latest
needs: [ prepare-release ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: ${{ vars.GCP_RELEASE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_RELEASE_SERVICE_ACCOUNT_EMAIL }}
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: ${{ vars.GCP_RELEASE_IMAGE_REGISTRY_URI }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout latest tag
run: |
CURRENT_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout tags/${CURRENT_VERSION}
echo "STARTER_IMAGE_TAG=${CURRENT_VERSION:1}" >> $GITHUB_ENV
- name: Build and push CMS image to GAR
run: docker buildx build --platform linux/amd64,linux/arm64 --push -t europe-docker.pkg.dev/websight-io/public/websight-cms-starter:${{ env.STARTER_IMAGE_TAG }} .