update-submodules #51
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: 🎯 GitOps Trigger | |
on: | |
repository_dispatch: | |
types: [ update-submodules ] | |
env: | |
repo_name: ${{ github.event.client_payload.repo_name }} | |
tag: ${{ github.event.client_payload.tag }} | |
jobs: | |
update_modules: | |
name: Update Submodules | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate inputs | |
run: | | |
[[ "${{ env.repo_name }}" ]] || { echo "Input \"repo_name\" cannot be empty" ; exit 1; } | |
[[ "${{ env.tag }}" ]] || { echo "Input \"tag\" cannot be empty" ; exit 1; } | |
- name: Create authentication token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.KEYSTONE_GITOPS_ID }} | |
private-key: ${{ secrets.KEYSTONE_GITOPS_PK }} | |
owner: ${{ github.repository_owner }} | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Update submodule | |
working-directory: docs/submodules/${{ env.repo_name }} | |
run: | | |
echo "Updating $(pwd)" | |
git fetch --tags | |
git checkout ${{ env.tag }} | |
- name: Update parent repository | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit --allow-empty -m "Updates ${{ env.repo_name }} to ${{ env.tag }}" | |
git push | |
build: | |
name: Build | |
needs: update_modules | |
uses: ./.github/workflows/Build.yml | |
secrets: inherit | |
with: | |
tag: "main" # Manually specify main so build uses the commit from the previous step | |
publish: | |
name: Publish | |
needs: build | |
uses: ./.github/workflows/Publish.yml |