Release to QA #213
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
# Releases from master branch to QA staging server. | |
name: "Release to QA" | |
concurrency: deploy-staging | |
on: | |
schedule: | |
# Run every day except Tuesday, at 01:30 UTC, shortly before beginning of tester workday. | |
# Note that this workflow can be disabled from the GitHub UI by going to | |
# Actions > Workflows > Release to QA > "..." > Disable workflow | |
- cron: "30 1 * * 0-1,3-6" | |
workflow_dispatch: | |
inputs: | |
skip-branch-update: | |
description: "Skip updating the release branch, and just release the tip of the branch as it currently exists. This can be used to release a hotfix, provided you've already pushed it to the release branch." | |
required: true | |
type: boolean | |
default: false | |
re-release: | |
description: "Build and release even if the build commit already has a release tag." | |
required: true | |
type: boolean | |
default: false | |
jobs: | |
determine_build_commit: | |
name: "Determine commit from which to build" | |
runs-on: ubuntu-latest | |
outputs: | |
build_commit: "${{ steps.get_commit.outputs.build_commit }}" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Use latest branch master | |
if: ${{ github.event.inputs.skip-branch-update == 'false' }} | |
run: git checkout master | |
- name: Use existing branch sf-qa | |
if: ${{ github.event.inputs.skip-branch-update == 'true' }} | |
run: git checkout sf-qa | |
- name: Get commit | |
id: get_commit | |
run: | | |
set -xueo pipefail | |
build_commit="$(git rev-parse HEAD)" | |
echo "build_commit=${build_commit}" >> $GITHUB_OUTPUT | |
- name: Details on selected build commit | |
run: | | |
set -u | |
build_commit="${{ steps.get_commit.outputs.build_commit }}" | |
echo "Using build_commit: ${build_commit}" | |
echo " " | |
echo "git describe: $(git describe "${build_commit}")" | |
echo " " | |
echo "Commit details:" | |
git show --stat "${build_commit}" | |
echo " " | |
echo "Commit and ancestors:" | |
git log --graph --decorate=short --oneline --abbrev=9 --max-count 5 "${build_commit}" | |
echo " " | |
echo "Commit in context of other branches:" | |
build_commit_abbrev="${build_commit:0:9}" | |
git log --graph --decorate=short --oneline --abbrev=9 --max-count 100 origin/sf-live origin/sf-qa origin/master | grep "${build_commit_abbrev}" --context=7 | perl -p -e "s/${build_commit_abbrev}/${build_commit_abbrev} <--/" | |
stop_if_already_built: | |
# Do not build again if the commit has already been built from and tagged. | |
name: "Stop if already built" | |
needs: determine_build_commit | |
outputs: | |
already_built: "${{ steps.check_if_already_built.outputs.already_built }}" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.determine_build_commit.outputs.build_commit }} | |
fetch-depth: "0" | |
- name: Check if already built | |
id: check_if_already_built | |
run: | | |
set -xueo pipefail | |
TAGS=$(git tag --points-at "${{ needs.determine_build_commit.outputs.build_commit }}") | |
PATTERN='^SF-QAv[0-9.]+$' | |
# Does the current commit have any tags like this? | |
MATCH=false | |
for TAG in $TAGS; do | |
if [[ $TAG =~ $PATTERN ]]; then | |
MATCH=true | |
break | |
fi | |
done | |
echo "already_built=${MATCH}" >> $GITHUB_OUTPUT | |
determine_version: | |
name: "Determine version" | |
needs: [determine_build_commit, stop_if_already_built] | |
if: ${{ needs.stop_if_already_built.outputs.already_built == 'false' || github.event.inputs.re-release == 'true' }} | |
uses: ./.github/workflows/compute-next-version.yml | |
with: | |
versioning-system: "staging" | |
tag_prefix: "SF-QAv" | |
release_branch: "sf-qa" | |
deploy: | |
name: "Deploy to QA" | |
needs: [determine_build_commit, determine_version] | |
secrets: inherit | |
uses: ./.github/workflows/release.yml | |
with: | |
environment: "qa_deploy" | |
build_commit: ${{ needs.determine_build_commit.outputs.build_commit }} | |
release_branch: "sf-qa" | |
dotnet_version: "8.0.x" | |
node_version: "18.20.2" | |
npm_version: "10.9.0" | |
os: "ubuntu-20.04" | |
angular_config: "staging" | |
app_name: "scriptureforge" | |
app_suffix: "_qa" | |
version_number: "${{ needs.determine_version.outputs.next_version }}" | |
vcs_tag_prefix: "SF-QAv" | |
node_options: "--max_old_space_size=4096" | |
project: "SIL.XForge.Scripture" | |
server_domain_name: "qa.scriptureforge.org" |