-
Notifications
You must be signed in to change notification settings - Fork 1
feat(submodule-workflow): create pre-release and update IONOS submodu… #86
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| # SPDX-FileCopyrightText: 2024 IONOS Productivity | ||||||
| # SPDX-License-Identifier: MIT | ||||||
| name: Trigger ncw-server submodule update | ||||||
| name: Create pre-release and update ncw-server submodule | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
|
|
@@ -13,62 +13,187 @@ permissions: | |||||
| pull-requests: write | ||||||
|
|
||||||
| jobs: | ||||||
| get-commit-info: | ||||||
| runs-on: [self-hosted] | ||||||
| create-prerelease: | ||||||
| runs-on: [ubuntu-latest] | ||||||
| outputs: | ||||||
| sha: ${{ steps.commit-info.outputs.sha }} | ||||||
| short_sha: ${{ steps.commit-info.outputs.short_sha }} | ||||||
| message: ${{ steps.commit-info.outputs.message }} | ||||||
| author: ${{ steps.commit-info.outputs.author }} | ||||||
| tag_name: ${{ steps.commit-info.outputs.short_sha }} | ||||||
| release_url: ${{ steps.create-release.outputs.html_url }} | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout repository | ||||||
| uses: actions/checkout@v4 | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| fetch-depth: 1 | ||||||
| fetch-depth: 0 | ||||||
|
|
||||||
| - name: Get commit information | ||||||
| id: commit-info | ||||||
| run: | | ||||||
| echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||||||
| echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||||||
| echo "message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT | ||||||
| echo "author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT | ||||||
|
|
||||||
| call-submodule-update: | ||||||
| needs: get-commit-info | ||||||
| runs-on: [self-hosted] | ||||||
|
|
||||||
| - name: Check GitHub CLI installation | ||||||
| id: check-gh | ||||||
| run: | | ||||||
| if command -v gh &> /dev/null; then | ||||||
| echo "installed=true" >> $GITHUB_OUTPUT | ||||||
| else | ||||||
| echo "installed=false" >> $GITHUB_OUTPUT | ||||||
| fi | ||||||
|
|
||||||
| - name: Install GitHub CLI | ||||||
| if: steps.check-gh.outputs.installed != 'true' | ||||||
| run: | | ||||||
| echo "Installing GitHub CLI..." | ||||||
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | ||||||
| sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | ||||||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/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 pre-release | ||||||
| id: create-release | ||||||
| env: | ||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
| run: | | ||||||
| # Check if the release already exists | ||||||
| if gh release view "${{ steps.commit-info.outputs.short_sha }}" --repo "${{ github.repository }}" > /dev/null 2>&1; then | ||||||
| # Release exists, get its URL | ||||||
| RELEASE_URL=$(gh release view "${{ steps.commit-info.outputs.short_sha }}" --repo "${{ github.repository }}" --json url -q ".url") | ||||||
| else | ||||||
| # Release does not exist, create it | ||||||
| RELEASE_URL=$(gh release create "${{ steps.commit-info.outputs.short_sha }}" \ | ||||||
| --title "Pre-release ${{ steps.commit-info.outputs.short_sha }}" \ | ||||||
| --generate-notes \ | ||||||
| --prerelease \ | ||||||
| --repo "${{ github.repository }}") | ||||||
| fi | ||||||
| echo "html_url=$RELEASE_URL" >> $GITHUB_OUTPUT | ||||||
|
|
||||||
| create-submodule-pr: | ||||||
| needs: create-prerelease | ||||||
| runs-on: [ubuntu-latest] | ||||||
| if: github.repository == 'IONOS-Productivity/ncw-config' | ||||||
|
|
||||||
| steps: | ||||||
| - name: Trigger ncw-server submodule update workflow | ||||||
| - name: Checkout ncw-server repository | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| repository: IONOS-Productivity/ncw-server | ||||||
| token: ${{ secrets.NCW_SERVER_PAT }} | ||||||
| ref: ionos-dev | ||||||
| fetch-depth: 1 | ||||||
| sparse-checkout: | | ||||||
| IONOS | ||||||
| .gitmodules | ||||||
|
|
||||||
| - name: Check GitHub CLI installation | ||||||
| id: check-gh | ||||||
| run: | | ||||||
| curl -X POST \ | ||||||
| -H "Accept: application/vnd.github.v3+json" \ | ||||||
| -H "Authorization: token ${{ secrets.SUBMODULE_UPDATE_PAT }}" \ | ||||||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||||||
| https://api.github.com/repos/IONOS-Productivity/ncw-server/dispatches \ | ||||||
| -d '{ | ||||||
| "event_type": "submodule-update", | ||||||
| "client_payload": { | ||||||
| "submodule_name": "IONOS", | ||||||
| "submodule_repo": "${{ github.repository }}", | ||||||
| "commit_sha": "${{ needs.get-commit-info.outputs.sha }}", | ||||||
| "commit_message": "${{ needs.get-commit-info.outputs.message }}", | ||||||
| "trigger_repo": "${{ github.repository }}", | ||||||
| "trigger_ref": "${{ github.ref }}" | ||||||
| } | ||||||
| }' | ||||||
| if command -v gh &> /dev/null; then | ||||||
| echo "installed=true" >> $GITHUB_OUTPUT | ||||||
| else | ||||||
| echo "installed=false" >> $GITHUB_OUTPUT | ||||||
| fi | ||||||
|
|
||||||
| - name: Install GitHub CLI | ||||||
| if: steps.check-gh.outputs.installed != 'true' | ||||||
| run: | | ||||||
| echo "Installing GitHub CLI..." | ||||||
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | ||||||
| sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | ||||||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/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 | ||||||
printminion-co marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| - name: Update IONOS submodule | ||||||
| run: | | ||||||
| git config user.name "github-actions[bot]" | ||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||
|
|
||||||
| # Configure git to use HTTPS instead of SSH for GitHub | ||||||
| git config --global url."https://github.com/".insteadOf "[email protected]:" | ||||||
| git config --global url."https://".insteadOf "ssh://" | ||||||
|
Comment on lines
+116
to
+117
|
||||||
| git config --global url."https://github.com/".insteadOf "[email protected]:" | |
| git config --global url."https://".insteadOf "ssh://" |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The COMMIT_MSG variable is retrieved twice (lines 126 and 149) from the IONOS submodule, which is redundant. Consider setting it once as an environment variable or output in the "Update IONOS submodule" step and reusing it in the "Create Pull Request" step to improve maintainability.
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RELEASE_URL is constructed twice (lines 130 and 152) with identical logic. This duplication should be avoided. Consider constructing it once in the "Update IONOS submodule" step and exporting it as an environment variable or job output for reuse in the "Create Pull Request" step.
Uh oh!
There was an error while loading. Please reload this page.