Skip to content
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

GHA: update docs when we merge to a release branch. #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions .github/workflows/website-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: website-updates
on:
push:
branches:
- release/*

jobs:
repatriate-to-lts:
runs-on: ubuntu-latest

name: update-website-docs

env:
REF: ${{ github.ref }}
RUN: ${{ github.run_id }}
PUSH_ID: ${{ github.event.push_id }}
WEB_REPO: ${{ secrets.WEBSITE_REPO }}
GH_TAIL_REF: ${{ github.event.before }}
GIT_API_KEY: ${{ secrets.GH_GITHUB_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_USER_NAME: ${{ secrets.GH_AUTO_USER }}
GIT_USER_EMAIL: ${{ secrets.GH_AUTO_EMAIL }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Git setup
shell: bash
run: |
git config --global user.email "$GIT_USER_EMAIL"
git config --global user.name "$GIT_USER_NAME"
git config --global --remove-section url."ssh://git@github.com" || true
git config --global "url.https://$GIT_API_KEY@github.com.insteadof" https://github.com

- name: Get yq
shell: bash
run: |
sudo snap install yq

- name: Install git subtree
shell: bash
run: |
sudo curl -fL https://github.com/raw/LukeShu/git/lukeshu/next/2021-05-15/contrib/subtree/git-subtree.sh -o $(git --exec-path)/git-subtree && sudo chmod 755 $(git --exec-path)/git-subtree

- name: Get website repo
shell: bash
run: |
git clone https://github.com/$WEB_REPO.git /tmp/getambassador.io

- name: Get version
shell: bash
id: version
run: |
echo "::set-output name=version::$(yq eval .items.0.version docs/releaseNotes.yml)"

#- name: Get released item
# shell: bash
# run: |
# yq eval .items.0 docs/releaseNotes.yml > /tmp/item.yml
# TODO: fix broken subtrees in docs repo and call a script to update .Y release

- name: Temporarily block .Y releases
shell: bash
run: |
[[ ! "${{steps.version.outputs.version}}" == *.0 ]]
[[ ! "${{steps.version.outputs.version}}" == *.0-* ]]

- name: Insert new version notes into docs repo
shell: bash
run: |
set -x
export LONG=${{steps.version.outputs.version}}
export SHORT=$(echo ${LONG%.*-*} | cut -d. -f1-2)
#export ITEM=$(cat /tmp/item.yml)
#yq eval-all '.items |= [env(ITEM)] + .' /tmp/getambassador.io/ambassador-docs/docs/edge-stack/$SHORT/releaseNotes.yml
#yq eval-all '.items |= [env(ITEM)] + .' /tmp/getambassador.io/ambassador-docs/docs/emissary/$SHORT/releaseNotes.yml
cp docs/releaseNotes.yml /tmp/getambassador.io/ambassador-docs/docs/edge-stack/$SHORT/releaseNotes.yml

- name: Prerelease docs update
shell: bash
# according to Luke this will hit only and all pre-releases
if: contains(steps.version.outputs.version, '-')
run: |
#export ITEM=$(cat /tmp/item.yml)
#yq eval-all '.items |= [env(GITEM)] + .' /tmp/getambassador.io/ambassador-docs/docs/edge-stack/pre-release/releaseNotes.yml
#yq eval-all '.items |= [env(GITEM)] + .' /tmp/getambassador.io/ambassador-docs/docs/emissary/pre-release/releaseNotes.yml
cp docs/releaseNotes.yml /tmp/getambassador.io/ambassador-docs/docs/edge-stack/pre-release/releaseNotes.yml

- name: Update website repo
shell: bash
run: |
set -x
pushd /tmp/getambassador.io
git checkout -b rel/edge-stack/v${{steps.version.outputs.version}}
git add .
git commit -s -m "Update ambassador-docs subtree to latest following Edge Stack ${{steps.version.outputs.version}} release"
git push --set-upstream origin rel/edge-stack/v${{steps.version.outputs.version}}

- name: Initialize Pull Request
id: pr
uses: vsoch/pull-request-action@master
env:
PULL_REQUEST_REPOSITORY: ${{ secrets.WEBSITE_REPO }}
PULL_REQUEST_TOKEN: ${{ secrets.GH_API_KEY }}
PULL_REQUEST_FROM_BRANCH: rel/edge-stack/v${{ steps.version.outputs.version }}
PULL_REQUEST_BRANCH: master
PULL_REQUEST_TITLE: '[CI] [v${{ steps.version.outputs.version }}] Release Branch'
PULL_REQUEST_BODY: >-
This PR contains updates from Edge Stack release ${{steps.version.outputs.version}}

#- name: Push docs
# shell: bash
# run: |
# pushd /tmp/getambassador.io
# make push-docs

- name: Slack notification
if: always()
uses: edge/simple-slack-notify@master
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
success_text: "Created website update PR for v${{steps.version.outputs.version}}"
failure_text: "Website update PR failed"
fields: |
[{ "title": "Repository", "value": "${env.GITHUB_REPOSITORY}", "short": true },
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true}]