-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update examples link during release process (#2148)
* chore: Update examples link during release process * add comment * fix: make commits run one after another * adjust name for commit author
- Loading branch information
1 parent
7146a46
commit eb01c2d
Showing
4 changed files
with
98 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,40 +32,48 @@ jobs: | |
with: | ||
atlas_cloud_env: "qa" | ||
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }} | ||
|
||
update-examples-reference-in-docs: | ||
needs: [ validate-version-input, run-qa-acceptance-tests ] | ||
if: >- | ||
always() | ||
&& inputs.use_existing_tag != 'true' | ||
&& !contains(inputs.version_number, 'pre') | ||
&& needs.validate-version-input.result == 'success' | ||
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') | ||
uses: ./.github/workflows/run-script-and-commit.yml | ||
with: | ||
script_call: './scripts/update-examples-reference-in-docs.sh ${{inputs.version_number}}' | ||
file_to_commit: 'website/docs/index.html.markdown' | ||
commit_message: 'Update examples link in index.html.markdown for ${{ github.event.inputs.version_number }} release' | ||
user_email: '[email protected]' | ||
user_name: 'releasebot' | ||
|
||
update-changelog-header: | ||
runs-on: ubuntu-latest | ||
needs: [ validate-version-input, run-qa-acceptance-tests ] | ||
# Skipped if use_existing_tag is defined, is a pre-release, or previous jobs failed. | ||
needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs ] | ||
if: >- | ||
always() | ||
&& inputs.use_existing_tag != 'true' | ||
&& !contains(inputs.version_number, 'pre') | ||
&& needs.validate-version-input.result == 'success' | ||
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 | ||
with: | ||
fetch-depth: 0 | ||
- run: ./scripts/update-changelog-header-for-release.sh ${{inputs.version_number}} | ||
- run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
MSG="Update CHANGELOG.md header for ${{inputs.version_number}} release" | ||
git config --local user.email [email protected] | ||
git config --local user.name changelogbot | ||
git add CHANGELOG.md | ||
git commit -m "$MSG" | ||
git push | ||
fi | ||
uses: ./.github/workflows/run-script-and-commit.yml | ||
with: | ||
script_call: './scripts/update-changelog-header-for-release.sh ${{inputs.version_number}}' | ||
file_to_commit: 'CHANGELOG.md' | ||
commit_message: 'Update CHANGELOG.md header for ${{ github.event.inputs.version_number }} release' | ||
user_email: '[email protected]' | ||
user_name: 'releasebot' | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: [ validate-version-input, run-qa-acceptance-tests, update-changelog-header ] | ||
needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs, update-changelog-header ] | ||
# Release is skipped if there are failures in previous steps | ||
if: >- | ||
always() | ||
&& needs.validate-version-input.result == 'success' | ||
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') | ||
&& (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success') | ||
&& (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success') | ||
steps: | ||
- name: Checkout | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Run Script and Commit Changes | ||
|
||
# Unifies logic for running a script and commit specific changes to master. Used during release process and for updating changelog on merged PRs. | ||
on: | ||
workflow_call: | ||
inputs: | ||
script_call: | ||
required: true | ||
type: string | ||
file_to_commit: | ||
required: true | ||
type: string | ||
commit_message: | ||
required: true | ||
type: string | ||
user_email: | ||
required: true | ||
type: string | ||
user_name: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
run_script_and_commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run specified script | ||
run: ${{ inputs.script_call }} | ||
|
||
- name: Commit changes | ||
run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
git pull | ||
git config --local user.email ${{ inputs.user_email }} | ||
git config --local user.name ${{ inputs.user_name }} | ||
git add ${{ inputs.file_to_commit }} | ||
git commit -m "${{ inputs.commit_message }}" | ||
git push | ||
else | ||
echo "No changes to commit." | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
: "${1?"Tag of new release must be provided"}" | ||
|
||
FILE_PATH="./website/docs/index.html.markdown" | ||
RELEASE_TAG=$1 | ||
|
||
# Define the old URL pattern and new URL | ||
OLD_URL_PATTERN="\[example configurations\](https:\/\/github.com\/mongodb\/terraform-provider-mongodbatlas\/tree\/[a-zA-Z0-9._-]*\/examples)" | ||
NEW_URL="\[example configurations\](https:\/\/github.com\/mongodb\/terraform-provider-mongodbatlas\/tree\/$RELEASE_TAG\/examples)" | ||
|
||
|
||
TMP_FILE_NAME="docs.tmp" | ||
rm -f $TMP_FILE_NAME | ||
|
||
# Use sed to update the URL and write to temporary file | ||
sed "s|$OLD_URL_PATTERN|$NEW_URL|g" "$FILE_PATH" > "$TMP_FILE_NAME" | ||
|
||
# Move temporary file to original file | ||
mv "$TMP_FILE_NAME" "$FILE_PATH" | ||
|
||
echo "Link updated successfully in $FILE_PATH" |
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