-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Update examples link during release process #2148
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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: 'changelogbot' | ||
|
||
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. | ||
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: 'changelogbot' | ||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Run Script and Commit Changes | ||
|
||
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 |
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] Curious why we are not using "in-place" ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Went for this approach initially but the implementation of sed in macOS vs Linux handles the |
||
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted this as it will also contain logic for commit signing and configuring github PAT.