-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Download Page for Alpha Release
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Update Download Page for Alpha Release | ||
# could be workflow_dispatch? | ||
on: [workflow_call] | ||
inputs: | ||
version: | ||
description: 'The version of the alpha release' | ||
required: true | ||
DRI: | ||
description: 'The release DRIs github nick' | ||
required: true | ||
date: | ||
description: 'The release date' | ||
required: true | ||
jobs: | ||
update-doc: | ||
runs-on: ubuntu-latest | ||
name: update static docs | ||
steps: | ||
- name: Import Secrets | ||
id: secrets | ||
uses: hashicorp/[email protected] | ||
with: | ||
url: ${{ secrets.VAULT_ADDR }} | ||
method: approle | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
exportEnv: false | ||
secrets: | | ||
secret/data/products/cambpm/ci/github-workflow GITHUB_APP_ID; | ||
secret/data/products/cambpm/ci/github-workflow GITHUB_APP_PRIVATE_KEY; | ||
- name: Generate token for GitHub | ||
id: generate-github-token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ steps.secrets.outputs.GITHUB_APP_ID }} | ||
private_key: ${{ steps.secrets.outputs.GITHUB_APP_PRIVATE_KEY }} | ||
- name: Checkout camunda-docs-static dir | ||
id: release-update-download-page | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: camunda/camunda-docs-static | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
path: camunda-docs-static | ||
ref: ${{ inputs.ref }} # github.job_workflow_sha seems to be the documented parameter to resolve this, but doesn't | ||
- name: Update Download Page and Create PR for alpha release | ||
id: release-create-pr | ||
uses: camunda/automation-platform-github-actions/release-update-download-page@main | ||
with: | ||
version: ${{ input.version }} | ||
date: ${{ inputs.date }} | ||
DRI: ${{ inputs.DRI }} | ||
GITHUB_TOKEN: ${{ steps.generate-github-token.outputs.token }} |
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,27 @@ | ||
name: 'Update Download Page and Create PR for alpha release' | ||
description: 'Updated the download options after an alpha release is available' | ||
inputs: | ||
version: | ||
description: 'The version of the alpha release' | ||
required: true | ||
DRI: | ||
description: 'The release DRIs github nick' | ||
required: true | ||
date: | ||
description: 'The release date' | ||
required: true | ||
GITHUB_TOKEN: | ||
description: 'Github Token' | ||
required: true | ||
runs: | ||
- name: Update Download ReadME | ||
env: | ||
minorVersion: ${{ input.version }} | ||
releaseDate: ${{ inputs.date }} | ||
run: ./update-docs.sh | ||
- name: Create pull-request | ||
env: | ||
GITHUB_WORKSPACE: ${{GITHUB_WORKSPACE}} | ||
DRI: ${{ inputs.DRI }} | ||
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
run: ./create-pr.sh |
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,53 @@ | ||
#!/bin/bash | ||
# expected env vars: | ||
# GITHUB_WORKSPACE 'The github workplace' | ||
# GH_TOKEN 'Personal access token used by github cli' | ||
# DRI 'DRI of the release' | ||
|
||
BRANCH_NAME="update-docs-for-alpha-release" | ||
REPO_DIR=$GITHUB_WORKSPACE"camunda-docs-static" | ||
|
||
cd $REPO_DIR | ||
if [ "$(pwd)" != "$REPO_DIR" ]; then | ||
echo "Error: Failed to change to correct directory. Exiting." | ||
exit 1 | ||
fi | ||
|
||
# Create a new feature branch, commit and push | ||
git checkout -b $BRANCH_NAME | ||
git add . | ||
git commit -m "chore(relese): update download page for alpha release" | ||
|
||
# Check if the current branch is correct | ||
current_branch=$(git branch --show-current) | ||
|
||
if [[ "$current_branch" == "$BRANCH_NAME" ]]; then | ||
echo "Branch check passed, pushing to $BRANCH_NAME..." | ||
if git push --set-upstream origin $BRANCH_NAME | ||
then | ||
echo "git push succeeded" | ||
else | ||
echo "git push failed. Exiting." | ||
exit 1 | ||
fi | ||
else | ||
echo "Error: Was not able to check out new branch $BRANCH_NAME. Exiting." | ||
exit 1 | ||
fi | ||
|
||
# create a pull request | ||
gh pr create \ | ||
--body "Please review the changes for the alpha release documentation." \ | ||
--title "chore(relese): update download page for alpha release" \ | ||
--head "$BRANCH_NAME" \ | ||
--base "master" \ | ||
--assignee "$DRI" \ | ||
--reviewer "$DRI" | ||
|
||
# Capture the exit status of the GitHub CLI command | ||
exit_status=$? | ||
if [ $exit_status -eq 0 ]; then | ||
echo "Pull request created successfully." | ||
else | ||
echo "Failed to create pull request. Exit status: $exit_status" | ||
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,37 @@ | ||
#!/bin/bash | ||
|
||
# expected env vars: | ||
# minorVersion 'The version of the alpha release' | ||
# releaseDate 'The release date' | ||
|
||
minorVersion=$(echo $nextVersion | cut -c1-4) | ||
branchVar=" - branch: \"$minorVersion\"" | ||
header=" - branch: \"$minorVersion\" | ||
releases: | ||
" | ||
|
||
if [[ "$input_content" == *"$branchVar"* ]]; then | ||
echo "this is a problem!" | ||
lineNumber=$(grep -n -m1 "releases:" $filePath | cut -d: -f1) | ||
header="" | ||
else | ||
lineNumber=$(grep -n -m1 'branches:' $filePath | cut -d: -f1) | ||
fi | ||
|
||
filePath="$GITHUB_WORKSPACE/camunda-docs-static/enterprise/content/download.md" | ||
input_content=$(<"$filePath") | ||
extracted_section=$(echo "$input_content" | awk '/releases:/{flag=1; next} flag && /^$/ {exit} flag') | ||
|
||
# White spaces are important for indentation | ||
number=" - number: \"$nextVersion\"" | ||
note=" note: \"https://github.com/camunda/camunda-bpm-platform/issues?q=is%3Aissue+is%3Aclosed+label%3Aversion%3A$nextVersion\"" | ||
date=" date: \"$releaseDate\"" | ||
|
||
updated_text=$(echo "$extracted_section" | sed "s@.*note: .*@$note@g" | sed "s@.*number: .*@$number@g" | sed "s@.*date: .*@$date@g") | ||
|
||
temp_file=$(mktemp) | ||
printf "$header $updated_text \n\n" > "$temp_file" | ||
|
||
# to run on mac: sed -i "" "${lineNumber}r $temp_file" "$filePath" | ||
sed -i "${lineNumber}r $temp_file" "$filePath" | ||
rm "$temp_file" |