update-docs #50
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
name: Update Documentation | |
on: | |
repository_dispatch: | |
types: [update-docs] | |
jobs: | |
update-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout VaporDocumentationWebsite repo | |
uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Fetch latest release info | |
id: fetch_release | |
run: | | |
latest_release=$(curl -H "Accept: application/vnd.github.v4+json" https://api.github.com/repos/ifranda/VAPOR/releases/latest) | |
release_name=$(echo $latest_release | jq -r .tag_name) | |
release_notes=$(echo $latest_release | jq -r .body) | |
echo "RELEASE_NAME=$release_name" >> $GITHUB_ENV | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$release_notes" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Update current file | |
run: | | |
current_name="docs/announcements/current.rst" | |
echo ".. _current:" > "$current_name" | |
echo "" >> "$current_name" | |
echo "Current Release" >> "$current_name" | |
echo "---------------" >> "$current_name" | |
echo "" >> "$current_name" | |
echo ".. include:: ${RELEASE_NAME}.rst" >> "$current_name" | |
env: | |
RELEASE_NAME: ${{ env.RELEASE_NAME }} | |
- name: Update docs/downloads.rst and docs/index.rst | |
run: | | |
downloads_file="docs/downloads.rst" | |
sed -i "s|.. include:: announcements/.*.rst|.. include:: announcements/${RELEASE_NAME}.rst|g" "docs/downloads.rst" | |
sed -i "s|.. include:: announcements/.*.rst|.. include:: announcements/${RELEASE_NAME}.rst|g" "docs/index.rst" | |
env: | |
RELEASE_NAME: ${{ env.RELEASE_NAME }} | |
- name: Create release notes file | |
run: | | |
file_name="docs/announcements/${RELEASE_NAME}.rst" | |
echo "$RELEASE_NOTES" > "$file_name" | |
sed -i 's/^##\(.*\)/**\1 **\n/g' "$file_name" | |
tr -d $'\r' < "$file_name" | |
echo "" >> "$file_name" | |
echo "** Download Links **" >> "$file_name" | |
echo "https://github.com/ifranda/VAPOR/archive/refs/tags/${RELEASE_NAME}.zip" >> "$file_name" | |
echo "https://github.com/ifranda/VAPOR/archive/refs/tags/${RELEASE_NAME}.tar.gz" >> "$file_name" | |
cat "$file_name" | |
env: | |
RELEASE_NAME: ${{ env.RELEASE_NAME }} | |
RELEASE_NOTES: ${{ env.RELEASE_NOTES }} | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
activate-environment: VaporDocumentationWebsite | |
environment-file: environment.yml | |
auto-update-conda: true | |
python-version: 3.9 | |
- name: Build Sphinx documentation | |
run: | | |
conda init bash | |
source ~/.bashrc | |
conda activate VaporDocumentationWebsite | |
pip install sphinxcontrib-googleanalytics | |
cd docs | |
make html | |
cp -r html/* ../ | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "Add release notes and doc updates for ${RELEASE_NAME}" | |
git push | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
RELEASE_NAME: ${{ env.RELEASE_NAME }} |