Sync RoveComm Repos #12
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: Sync RoveComm Repos | |
on: | |
# push: | |
# branches: | |
# - master | |
workflow_dispatch: | |
jobs: | |
sync-repos: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- name: rovecomm | |
path: manifest | |
branch: dev | |
- name: rovecomm-typescript | |
path: manifest | |
branch: main | |
- name: rovecomm_cpp | |
path: data/RoveComm | |
branch: development | |
- name: rovecomm_python | |
path: manifest | |
branch: dev | |
- name: rovecomm_swift | |
path: Sources/RoveComm_Swift/Resources/Manifest | |
branch: development | |
fail-fast: false | |
steps: | |
- name: Checkout rovecomm_base | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git config --global credential.helper store | |
echo "https://x-access-token:${{ secrets.ALL_ROVECOMM }}@github.com" > ~/.git-credentials | |
- name: Get current commit SHA | |
id: get_sha | |
run: | | |
echo "::set-output name=sha::$(git rev-parse HEAD)" | |
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" | |
- name: Generate commit message | |
id: commit_msg | |
run: echo "::set-output name=msg::Update due to changes in RoveComm Manifest" | |
- name: Clone and update submodule for ${{ matrix.name }} | |
run: | | |
git clone https://github.com/mrdt-software/${{ matrix.name }}.git | |
cd ${{ matrix.name }} | |
git submodule update --init --recursive | |
cd ${{ matrix.path }} | |
git checkout ${{ steps.get_sha.outputs.sha }} | |
cd - | |
git add ${{ matrix.path }} | |
git commit -m "${{ steps.commit_msg.outputs.msg }}" | |
git checkout -b sync/${{ steps.get_sha.outputs.short_sha }} | |
git push origin sync/${{ steps.get_sha.outputs.short_sha }} | |
- name: Install GitHub CLI | |
run: | | |
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \ | |
&& sudo mkdir -p -m 755 /etc/apt/keyrings \ | |
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ | |
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ | |
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | |
&& sudo apt update \ | |
&& sudo apt install gh -y | |
- name: Create pull request for ${{ matrix.name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
REPO_NAME=${{ matrix.name }} | |
BRANCH_NAME="sync/${{ steps.get_sha.outputs.short_sha }}" | |
BASE_BRANCH=${{ matrix.branch }} | |
COMMIT_SHA=${{ steps.get_sha.outputs.sha }} | |
COMMIT_SHORT=${{ steps.get_sha.outputs.short_sha }} | |
COMMIT_URL="https://github.com/MRDT-Software/RoveComm_Base/commit/$COMMIT_SHA" | |
# Authorize GitHub CLI with the PAT | |
echo "${{ secrets.ALL_ROVECOMM }}" | gh auth login --with-token | |
# Create the pull request | |
gh pr create \ | |
--repo missourimrdt/$REPO_NAME \ | |
--head $BRANCH_NAME \ | |
--base $BASE_BRANCH \ | |
--title "Sync Manifest to $COMMIT_SHORT" \ | |
--body "This is an automated pull request to update the repository due to changes in the rovecomm manifest at commit $COMMIT_URL." |