Try Blacksmith runners in deploy workflow #821
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: Deploys | |
on: | |
workflow_dispatch: | |
inputs: | |
stable: | |
description: 'Use upstream stable build' | |
required: true | |
type: string | |
default: 'true' | |
release: | |
description: 'Deploy a new release' | |
required: false | |
type: string | |
default: 'true' | |
skip-test: | |
description: 'Skip the tests' | |
required: false | |
type: boolean | |
default: false | |
skip-commit: | |
description: 'Skip the commit' | |
required: false | |
type: boolean | |
default: false | |
skip-build-push-image: | |
description: 'Skip the build & push images' | |
required: false | |
type: boolean | |
default: false | |
push: | |
branches: | |
- trunk | |
jobs: | |
build-test: | |
name: Build and Test | |
if: contains(toJson(github.event.commits), '[deploy]') == true || (github.event_name == 'workflow_dispatch' && github.event.inputs.skip-test == 'false') | |
uses: ./.github/workflows/build-test.yml | |
with: | |
release: ${{ github.event.inputs.stable || true }} | |
deploy: | |
needs: | |
- build-test | |
if: (contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && !failure() && !cancelled() | |
name: Deploy and Release | |
runs-on: blacksmith-16vcpu-ubuntu-2204 | |
permissions: write-all | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
large-packages: false | |
- name: Checkout code | |
uses: actions/checkout@main | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up containerd image store feature | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
make setup_dev_env | |
- name: Output Docker info | |
run: docker info | |
- name: Set Selenium base version | |
uses: ./.github/actions/get-latest-upstream | |
with: | |
release: ${{ github.event.inputs.stable || true }} | |
gh_cli_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sets build date | |
run: | | |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV | |
echo "NAME=${NAMESPACE}" >> $GITHUB_ENV | |
make set_build_multiarch | |
cat .env | xargs -I {} echo {} >> $GITHUB_ENV | |
env: | |
NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }} | |
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }} | |
- name: Sets prerelease to false by default | |
run: echo "PRERELEASE=false" >> $GITHUB_ENV | |
- name: Build base image to get Grid version | |
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base | |
- name: Get Grid version | |
# sed used to remove last comma of Selenium version output | |
run: echo "GRID_VERSION=$(docker run --rm ${NAME}/base:local-${BUILD_DATE} java -jar /opt/selenium/selenium-server.jar hub --version | awk '{print $3}' | sed 's/\(.*\),/\1 /')" | awk '{$1=$1;print}' >> $GITHUB_ENV | |
- name: Is it a prerelease? | |
run: echo "GRID_VERSION=${GRID_VERSION}-prerelease" >> $GITHUB_ENV && echo "PRERELEASE=true" >> $GITHUB_ENV | |
if: contains(toJson(github.event.commits), '[prerelease]') == true | |
- name: Display Grid version | |
run: echo ${GRID_VERSION} | |
- name: Sets env var for the next tag | |
run: echo "NEXT_TAG=${GRID_VERSION}-${BUILD_DATE}" >> $GITHUB_ENV | |
- name: Get latest tag | |
run: echo "LATEST_TAG=$(git tag --sort=-version:refname | grep "^[^selenium]" | head -n 1)" >> $GITHUB_ENV | |
- name: Display latest tag | |
run: echo ${LATEST_TAG} | |
- name: Update tag in docs and files | |
run: ./update_tag_in_docs_and_files.sh ${LATEST_TAG} ${NEXT_TAG} | |
- name: Update chart configuration docs | |
run: make generate_readme_charts | |
- name: Build Helm chart | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 5 | |
max_attempts: 3 | |
retry_wait_seconds: 10 | |
command: | | |
SET_VERSION=false make chart_build | |
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV | |
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV | |
- name: Render chart templates | |
run: | | |
make chart_render_template | |
echo "PUBLISH_YAML_MANIFESTS=$(find ./tests/tests -name "k8s_*.yaml" | tr '\n' ',')" >> $GITHUB_ENV | |
- name: Build images | |
if: github.event.inputs.skip-build-push-image != 'true' | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 90 | |
max_attempts: 3 | |
retry_wait_seconds: 60 | |
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build | |
- name: Login Docker Hub | |
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
- name: Deploy new images | |
if: github.event.inputs.skip-build-push-image != 'true' | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 20 | |
max_attempts: 5 | |
retry_wait_seconds: 300 | |
continue_on_error: true | |
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release | |
- name: Tag images as latest | |
if: github.event.inputs.skip-build-push-image != 'true' | |
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_latest | |
- name: Deploy latest tag | |
if: github.event.inputs.skip-build-push-image != 'true' | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 20 | |
max_attempts: 5 | |
retry_wait_seconds: 300 | |
continue_on_error: true | |
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_latest | |
- name: Update package versions | |
run: | | |
make generate_latest_sbom | |
make fetch_grid_scaler_resources | |
- name: Tag browser images | |
if: github.event.inputs.skip-build-push-image != 'true' | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 20 | |
max_attempts: 5 | |
retry_wait_seconds: 300 | |
continue_on_error: true | |
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true make tag_and_push_browser_images | |
- name: Delete previous nightly tag & release if any | |
uses: dev-drprasad/delete-tag-and-release@master | |
with: | |
tag_name: nightly | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
delete_release: true | |
- name: Commit files | |
if: env.LATEST_TAG != env.NEXT_TAG && github.event.inputs.skip-commit != 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Selenium CI Bot" | |
git commit -m "Update tag ${RELEASE_TAG} in docs and files" -a | |
env: | |
RELEASE_TAG: "${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}" | |
- name: Push changes | |
if: env.LATEST_TAG != env.NEXT_TAG && github.event.inputs.skip-commit != 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.SELENIUM_CI_TOKEN }} | |
branch: trunk | |
- name: Create release notes (release_notes.md) | |
run: ./generate_release_notes.sh ${LATEST_TAG} origin/trunk ${GRID_VERSION} ${BUILD_DATE} | |
- name: Upload release notes | |
uses: actions/upload-artifact@main | |
with: | |
name: release_notes | |
path: ./release_notes.md | |
if-no-files-found: ignore | |
- name: Create Release | |
if: env.LATEST_TAG != env.NEXT_TAG | |
id: create_release | |
uses: softprops/action-gh-release@master | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: "${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}" | |
name: "${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}" | |
body_path: "release_notes.md" | |
generate_release_notes: true | |
prerelease: ${{ env.PRERELEASE }} | |
draft: false | |
append_body: false | |
discussion_category_name: "Announcements" | |
files: | | |
package_versions.txt | |
${{ env.PUBLISH_YAML_MANIFESTS }} |