Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6da125fe99 | ||
|
|
f82412587d | ||
|
|
36f197aa6d | ||
|
|
05047ee5f7 |
No files matched your search
@@ -20,7 +20,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
||||||
permission-pull-requests: write # required to enable auto-merge
|
permission-pull-requests: write # required to enable auto-merge
|
||||||
|
|
||||||
- name: Install GitHub CLI
|
- name: Install GitHub CLI
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
||||||
permission-pull-requests: write # required to approve a pull request and enable auto-merge
|
permission-pull-requests: write # required to approve a pull request and enable auto-merge
|
||||||
|
|
||||||
- name: Install GitHub CLI
|
- name: Install GitHub CLI
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.CROWDIN_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.CROWDIN_APP_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.CROWDIN_APP_ID }}
|
client-id: ${{ secrets.CROWDIN_APP_ID }}
|
||||||
permission-contents: write # required to commit to crowdin branch
|
permission-contents: write # required to commit to crowdin branch
|
||||||
permission-pull-requests: write # required to create pull request
|
permission-pull-requests: write # required to create pull request
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
||||||
permission-pull-requests: write
|
permission-pull-requests: write
|
||||||
- name: Approve PR
|
- name: Approve PR
|
||||||
env:
|
env:
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # write to beta branch (due to merge)
|
permission-contents: write # write to beta branch (due to merge)
|
||||||
permission-pull-requests: write # merge pull request
|
permission-pull-requests: write # merge pull request
|
||||||
- id: automerge
|
- id: automerge
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ jobs:
|
|||||||
version: ${{ steps.read-semver.outputs.version || steps.version-fallback.outputs.version }}
|
version: ${{ steps.read-semver.outputs.version || steps.version-fallback.outputs.version }}
|
||||||
git_ref: ${{ steps.read-git-ref.outputs.ref || steps.read-semver.outputs.version || github.ref }}
|
git_ref: ${{ steps.read-git-ref.outputs.ref || steps.read-semver.outputs.version || github.ref }}
|
||||||
skipped: ${{ env.SKIP_RELEASE }}
|
skipped: ${{ env.SKIP_RELEASE }}
|
||||||
upstream_sync: ${{ steps.update-upstream.outcome }}
|
|
||||||
steps:
|
steps:
|
||||||
- run: echo "Manual dispatch redeploys the latest existing release without creating a new one"
|
- run: echo "Manual dispatch redeploys the latest existing release without creating a new one"
|
||||||
if: env.SKIP_RELEASE == 'true'
|
if: env.SKIP_RELEASE == 'true'
|
||||||
@@ -55,7 +54,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # required to commit package.json & changelog changes, merge them to dev / next and publish the release
|
permission-contents: write # required to commit package.json & changelog changes, merge them to dev / next and publish the release
|
||||||
|
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
@@ -116,10 +115,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||||
- name: Update dev / next branch
|
- name: Update dev / next branch
|
||||||
id: update-upstream
|
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
# Finish publishing the already-created release, then fail in the publish job if synchronization did not work.
|
continue-on-error: true # Prevent pipeline from failing when merge fails
|
||||||
continue-on-error: true
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
||||||
UPSTREAM_BRANCH: ${{ github.ref_name == 'main' && 'dev' || 'next' }}
|
UPSTREAM_BRANCH: ${{ github.ref_name == 'main' && 'dev' || 'next' }}
|
||||||
@@ -277,7 +274,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # required to publish the release
|
permission-contents: write # required to publish the release
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
@@ -314,12 +311,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
gh release edit --repo ${{ github.repository }} ${{ needs.release.outputs.version }} --draft=false
|
gh release edit --repo ${{ github.repository }} ${{ needs.release.outputs.version }} --draft=false
|
||||||
|
|
||||||
- name: Verify dev / next synchronization
|
|
||||||
if: needs.release.outputs.skipped == 'false' && needs.release.outputs.upstream_sync != 'success'
|
|
||||||
run: |
|
|
||||||
echo "::error::The released commit was not synchronized back to the upstream development branch."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Discord notification
|
- name: Discord notification
|
||||||
if: github.event_name != 'workflow_dispatch' || inputs['send-notifications']
|
if: github.event_name != 'workflow_dispatch' || inputs['send-notifications']
|
||||||
env:
|
env:
|
||||||
@@ -327,17 +318,3 @@ jobs:
|
|||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
with:
|
with:
|
||||||
args: "Successfully deployed images for branch **${{ github.ref_name }}**. Tagged as **${{env.NEXT_VERSION}}**."
|
args: "Successfully deployed images for branch **${{ github.ref_name }}**. Tagged as **${{env.NEXT_VERSION}}**."
|
||||||
|
|
||||||
notify-failure:
|
|
||||||
name: Notify deployment failure
|
|
||||||
if: ${{ always() && (failure() || cancelled()) && (github.event_name != 'workflow_dispatch' || inputs['send-notifications']) }}
|
|
||||||
needs: [release, build-amd64, build-arm64, extract-asset-amd64, extract-asset-arm64, publish]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 2
|
|
||||||
steps:
|
|
||||||
- name: Discord failure notification
|
|
||||||
env:
|
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
|
||||||
with:
|
|
||||||
args: "The deployment for branch **${{ github.ref_name }}** failed or was cancelled: [run ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
|
||||||
@@ -19,10 +19,10 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
create-and-merge-pr:
|
create-and-merge-pr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 2
|
||||||
steps:
|
steps:
|
||||||
- name: Discord notification
|
- name: Discord notification
|
||||||
if: ${{ github.event_name == 'schedule' || inputs.send-notifications }}
|
if: ${{ github.event.inputs.send-notifications }}
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
@@ -38,30 +38,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
branch: dev
|
branch: dev
|
||||||
noNewCommitBehavior: silent
|
|
||||||
noVersionBumpBehavior: silent
|
|
||||||
- name: No release needed
|
|
||||||
if: ${{ steps.semver.outputs.bump == '' || steps.semver.outputs.bump == 'none' }}
|
|
||||||
run: echo "No release-worthy commits were found since ${{ steps.semver.outputs.current }}." >> "$GITHUB_STEP_SUMMARY"
|
|
||||||
- name: Create pull request
|
- name: Create pull request
|
||||||
id: create-pull-request
|
id: create-pull-request
|
||||||
if: ${{ steps.semver.outputs.bump != '' && steps.semver.outputs.bump != 'none' }}
|
run: 'gh pr create --title "chore(release): automatic release ${{ steps.semver.outputs.next }}" --body "**This is an automatic release**.<br/>Manual action may be required for major bumps.<br/>Detected change to be ``${{ steps.semver.outputs.bump }}``<br/>Bump version from ``${{ steps.semver.outputs.current }}`` to ``${{ steps.semver.outputs.next }}``" --base main --head dev --label automerge'
|
||||||
run: |
|
|
||||||
pr_url="$(gh pr list --base main --head dev --state open --json url --jq '.[0].url // empty')"
|
|
||||||
if [[ -z "$pr_url" ]]; then
|
|
||||||
pr_url="$(gh pr create \
|
|
||||||
--title "chore(release): automatic release ${{ steps.semver.outputs.next }}" \
|
|
||||||
--body "**This is an automatic release**.<br/>Manual action may be required for major bumps.<br/>Detected change to be ``${{ steps.semver.outputs.bump }}``<br/>Bump version from ``${{ steps.semver.outputs.current }}`` to ``${{ steps.semver.outputs.next }}``" \
|
|
||||||
--base main \
|
|
||||||
--head dev \
|
|
||||||
--label automerge)"
|
|
||||||
fi
|
|
||||||
echo "url=$pr_url" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "pr_number=${pr_url##*/}" >> "$GITHUB_OUTPUT"
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
- name: Discord notification
|
- name: Discord notification
|
||||||
if: ${{ steps.create-pull-request.outcome == 'success' && (github.event_name == 'schedule' || inputs.send-notifications) }}
|
if: ${{ github.event.inputs.send-notifications }}
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
@@ -69,29 +52,26 @@ jobs:
|
|||||||
args: "Created a release PR ${{ steps.create-pull-request.outputs.url }} for version ${{ steps.semver.outputs.next }} (new behaviour: ${{ steps.semver.outputs.bump }})"
|
args: "Created a release PR ${{ steps.create-pull-request.outputs.url }} for version ${{ steps.semver.outputs.next }} (new behaviour: ${{ steps.semver.outputs.bump }})"
|
||||||
- name: Obtain token
|
- name: Obtain token
|
||||||
id: obtainApprovalToken
|
id: obtainApprovalToken
|
||||||
if: ${{ steps.create-pull-request.outcome == 'success' }}
|
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
||||||
permission-pull-requests: write
|
permission-pull-requests: write
|
||||||
- name: Approve PR
|
- name: Approve PR
|
||||||
if: ${{ steps.create-pull-request.outcome == 'success' }}
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ steps.obtainApprovalToken.outputs.token }}
|
GITHUB_TOKEN: ${{ steps.obtainApprovalToken.outputs.token }}
|
||||||
run: |
|
run: |
|
||||||
gh pr review "${{ steps.create-pull-request.outputs.url }}" --approve --body "Automatically approved by GitHub Action"
|
gh pr review --approve --body "Automatically approved by GitHub Action"
|
||||||
- name: Obtain token
|
- name: Obtain token
|
||||||
id: obtainMergeToken
|
id: obtainMergeToken
|
||||||
if: ${{ steps.create-pull-request.outcome == 'success' }}
|
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # write to main branch (due to merge)
|
permission-contents: write # write to main branch (due to merge)
|
||||||
permission-pull-requests: write # merge pull request
|
permission-pull-requests: write # merge pull request
|
||||||
- id: automerge
|
- id: automerge
|
||||||
if: ${{ steps.create-pull-request.outcome == 'success' && steps.semver.outputs.bump != 'major' }}
|
if: ${{ steps.semver.outputs.bump != 'major' }}
|
||||||
name: automerge
|
name: automerge
|
||||||
uses: "pascalgn/automerge-action@v0.16.4"
|
uses: "pascalgn/automerge-action@v0.16.4"
|
||||||
env:
|
env:
|
||||||
@@ -105,21 +85,21 @@ jobs:
|
|||||||
MERGE_REQUIRED_APPROVALS: 0 # do not require approvals
|
MERGE_REQUIRED_APPROVALS: 0 # do not require approvals
|
||||||
|
|
||||||
- name: Merged Discord notification
|
- name: Merged Discord notification
|
||||||
if: ${{ steps.automerge.outputs.mergeResult == 'merged' && (github.event_name == 'schedule' || inputs.send-notifications) }}
|
if: ${{ steps.automerge.outputs.mergeResult == 'merged' && github.event.inputs.send-notifications }}
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
with:
|
with:
|
||||||
args: "Merged PR ${{ steps.create-pull-request.outputs.url }} for release ${{ steps.semver.outputs.next }}"
|
args: "Merged PR ${{ steps.create-pull-request.outputs.url }} for release ${{ steps.semver.outputs.next }}"
|
||||||
- name: Major Bump Discord notification
|
- name: Major Bump Discord notification
|
||||||
if: ${{ steps.semver.outputs.bump == 'major' && (github.event_name == 'schedule' || inputs.send-notifications) }}
|
if: ${{ steps.semver.outputs.bump == 'major' && github.event.inputs.send-notifications }}
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
with:
|
with:
|
||||||
args: "The release PR must be manually merged because the next version is a major version: ${{ steps.create-pull-request.outputs.url }} for release ${{ steps.semver.outputs.next }}"
|
args: "The release PR must be manually merged because the next version is a major version: ${{ steps.create-pull-request.outputs.url }} for release ${{ steps.semver.outputs.next }}"
|
||||||
- name: Discord Fail Notification
|
- name: Discord Fail Notification
|
||||||
if: ${{ failure() && (github.event_name == 'schedule' || inputs.send-notifications) }}
|
if: failure() && github.event.inputs.send-notifications
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.4.0
|
uses: Ilshidur/action-discord@0.4.0
|
||||||
|
|||||||
@@ -5,6 +5,39 @@ on:
|
|||||||
types: [released]
|
types: [released]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
trigger-docs-release:
|
||||||
|
name: Trigger Documentation Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 2
|
||||||
|
steps:
|
||||||
|
- name: Obtain token
|
||||||
|
id: obtainToken
|
||||||
|
uses: actions/create-github-app-token@v3
|
||||||
|
with:
|
||||||
|
private-key: ${{ secrets.HOMARR_DOCS_RELEASE_APP_PRIVATE_KEY }}
|
||||||
|
client-id: ${{ vars.HOMARR_DOCS_RELEASE_APP_ID }}
|
||||||
|
owner: homarr-labs
|
||||||
|
repositories: |
|
||||||
|
documentation
|
||||||
|
permission-contents: write # required to dispatch repository workflow
|
||||||
|
- name: Trigger documentation release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
||||||
|
SOURCE_TAG: ${{ github.event.release.tag_name }}
|
||||||
|
run: |
|
||||||
|
curl -X POST \
|
||||||
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
https://api.github.com/repos/homarr-labs/documentation/dispatches \
|
||||||
|
-d @- <<EOF
|
||||||
|
{
|
||||||
|
"event_type": "trigger-release",
|
||||||
|
"client_payload": {
|
||||||
|
"tag": "${SOURCE_TAG}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
update-bug-report-template:
|
update-bug-report-template:
|
||||||
name: Update Bug Report Template
|
name: Update Bug Report Template
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -15,7 +48,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # required to commit to branch
|
permission-contents: write # required to commit to branch
|
||||||
permission-pull-requests: write # required to create pr & enable automerge
|
permission-pull-requests: write # required to create pr & enable automerge
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.HOMARR_UPDATE_CONTRIBUTORS_PRIVATE_KEY }}
|
private-key: ${{ secrets.HOMARR_UPDATE_CONTRIBUTORS_PRIVATE_KEY }}
|
||||||
app-id: ${{ vars.HOMARR_UPDATE_CONTRIBUTORS_APP_ID }}
|
client-id: ${{ vars.HOMARR_UPDATE_CONTRIBUTORS_APP_ID }}
|
||||||
permission-contents: write # required to commit to branch
|
permission-contents: write # required to commit to branch
|
||||||
permission-pull-requests: write # required to create pr & enable automerge
|
permission-pull-requests: write # required to create pr & enable automerge
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.HOMARR_UPDATE_CONTRIBUTORS_PRIVATE_KEY }}
|
private-key: ${{ secrets.HOMARR_UPDATE_CONTRIBUTORS_PRIVATE_KEY }}
|
||||||
app-id: ${{ vars.HOMARR_UPDATE_CONTRIBUTORS_APP_ID }}
|
client-id: ${{ vars.HOMARR_UPDATE_CONTRIBUTORS_APP_ID }}
|
||||||
permission-contents: write # required to commit to branch
|
permission-contents: write # required to commit to branch
|
||||||
permission-pull-requests: write # required to create pr & enable automerge
|
permission-pull-requests: write # required to create pr & enable automerge
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
@@ -202,9 +202,9 @@ Homarr supports multiple authentication options, from internal userbase (credent
|
|||||||
| ``AUTH_OIDC_CLIENT_NAME`` | Display name of provider (in login screen) | OIDC |
|
| ``AUTH_OIDC_CLIENT_NAME`` | Display name of provider (in login screen) | OIDC |
|
||||||
| ``AUTH_OIDC_AUTO_LOGIN`` | Automatically redirect to OIDC login | false |
|
| ``AUTH_OIDC_AUTO_LOGIN`` | Automatically redirect to OIDC login | false |
|
||||||
| ``AUTH_OIDC_SCOPE_OVERWRITE`` | Overwrite default scopes (openid, profile, email) | openid email profile groups |
|
| ``AUTH_OIDC_SCOPE_OVERWRITE`` | Overwrite default scopes (openid, profile, email) | openid email profile groups |
|
||||||
| ``AUTH_OIDC_GROUPS_ATTRIBUTE`` | Attribute used for groups (roles) claim | groups |
|
| ``AUTH_OIDC_GROUPS_ATTRIBUTE`` | Attribute used for groups (roles) claim. Dot-separated paths such as `resource_access.homarr.roles` are supported. | groups |
|
||||||
| ``AUTH_OIDC_GROUPS_LOCAL_MANAGEMENT`` | Stop syncing group memberships of OIDC users from the groups claim and manage them locally via the group members page instead | false |
|
| ``AUTH_OIDC_GROUPS_LOCAL_MANAGEMENT`` | Stop syncing group memberships of OIDC users from the groups claim and manage them locally via the group members page instead | false |
|
||||||
| ``AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE`` | Overwrite name attribute. By default it will use preferred_username if it does not contain a `@` and otherwise name. | --- |
|
| ``AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE`` | Overwrite name attribute. Dot-separated paths are supported. By default it will use preferred_username if it does not contain a `@` and otherwise name. | --- |
|
||||||
| ``AUTH_OIDC_FORCE_USERINFO`` | Force userinfo endpoint to be used for user information. | false |
|
| ``AUTH_OIDC_FORCE_USERINFO`` | Force userinfo endpoint to be used for user information. | false |
|
||||||
| ``AUTH_OIDC_ENABLE_DANGEROUS_ACCOUNT_LINKING`` | Enable account linking for OIDC provider. This will link the OIDC accounts by email. Be sure that you have verified emails to prevent stealing accounts. | false |
|
| ``AUTH_OIDC_ENABLE_DANGEROUS_ACCOUNT_LINKING`` | Enable account linking for OIDC provider. This will link the OIDC accounts by email. Be sure that you have verified emails to prevent stealing accounts. | false |
|
||||||
| ``AUTH_OIDC_ENABLE_DANGEROUS_CREDENTIALS_LINKING`` | Link an OIDC identity to an existing credentials user with the same email. The credentials login and existing user data are preserved. Requires the OIDC profile to contain `email_verified: true`. | false |
|
| ``AUTH_OIDC_ENABLE_DANGEROUS_CREDENTIALS_LINKING`` | Link an OIDC identity to an existing credentials user with the same email. The credentials login and existing user data are preserved. Requires the OIDC profile to contain `email_verified: true`. | false |
|
||||||
|
|||||||
+5
-10
@@ -9,7 +9,7 @@ import { groupMembers, groups, users } from "@homarr/db/schema";
|
|||||||
import { colorSchemeCookieKey, everyoneGroup } from "@homarr/definitions";
|
import { colorSchemeCookieKey, everyoneGroup } from "@homarr/definitions";
|
||||||
|
|
||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
import { extractProfileName } from "./providers/oidc/oidc-provider";
|
import { extractProfileName, getProfileValueByPath } from "./providers/oidc/profile";
|
||||||
|
|
||||||
const logger = createLogger({ module: "authEvents" });
|
const logger = createLogger({ module: "authEvents" });
|
||||||
|
|
||||||
@@ -31,16 +31,11 @@ export const createSignInEventHandler = (db: Database): Exclude<NextAuthConfig["
|
|||||||
if (!dbUser) throw new Error("User not found");
|
if (!dbUser) throw new Error("User not found");
|
||||||
|
|
||||||
const groupsKey = env.AUTH_OIDC_GROUPS_ATTRIBUTE;
|
const groupsKey = env.AUTH_OIDC_GROUPS_ATTRIBUTE;
|
||||||
|
const profileGroups = profile ? getProfileValueByPath(profile, groupsKey) : undefined;
|
||||||
// Groups from oidc provider are provided from the profile, it's not typed.
|
// Groups from oidc provider are provided from the profile, it's not typed.
|
||||||
if (
|
if (!env.AUTH_OIDC_GROUPS_LOCAL_MANAGEMENT && dbUser.provider === "oidc" && Array.isArray(profileGroups)) {
|
||||||
!env.AUTH_OIDC_GROUPS_LOCAL_MANAGEMENT &&
|
logger.debug(`Using profile groups (${groupsKey}): ${JSON.stringify(profileGroups)}`);
|
||||||
dbUser.provider === "oidc" &&
|
await synchronizeGroupsWithExternalForUserAsync(db, user.id, profileGroups as string[]);
|
||||||
profile &&
|
|
||||||
groupsKey in profile &&
|
|
||||||
Array.isArray(profile[groupsKey])
|
|
||||||
) {
|
|
||||||
logger.debug(`Using profile groups (${groupsKey}): ${JSON.stringify(profile[groupsKey])}`);
|
|
||||||
await synchronizeGroupsWithExternalForUserAsync(db, user.id, profile[groupsKey] as string[]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In ldap-authroization we return the groups from ldap, it's not typed.
|
// In ldap-authroization we return the groups from ldap, it's not typed.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/h
|
|||||||
|
|
||||||
import { env } from "../../env";
|
import { env } from "../../env";
|
||||||
import { createRedirectUri } from "../../redirect";
|
import { createRedirectUri } from "../../redirect";
|
||||||
|
import { extractProfileName } from "./profile";
|
||||||
import { assertVerifiedEmailForCredentialsLinking } from "./verified-email";
|
import { assertVerifiedEmailForCredentialsLinking } from "./verified-email";
|
||||||
|
|
||||||
export const OidcProvider = (headers: ReadonlyHeaders | null): OIDCConfig<Profile> => ({
|
export const OidcProvider = (headers: ReadonlyHeaders | null): OIDCConfig<Profile> => ({
|
||||||
@@ -76,12 +77,3 @@ export const OidcProvider = (headers: ReadonlyHeaders | null): OIDCConfig<Profil
|
|||||||
// @ts-expect-error `undici` has a `duplex` option
|
// @ts-expect-error `undici` has a `duplex` option
|
||||||
[customFetch]: fetchWithTrustedCertificatesAsync,
|
[customFetch]: fetchWithTrustedCertificatesAsync,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const extractProfileName = (profile: Profile) => {
|
|
||||||
if (!env.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE) {
|
|
||||||
// Use the name as the username if the preferred_username is an email address
|
|
||||||
return profile.preferred_username?.includes("@") ? profile.name : profile.preferred_username;
|
|
||||||
}
|
|
||||||
|
|
||||||
return profile[env.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE as keyof typeof profile] as string;
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import type { Profile } from "@auth/core/types";
|
||||||
|
|
||||||
|
import { env } from "../../env";
|
||||||
|
|
||||||
|
export const getProfileValueByPath = (profile: Profile, path: string): unknown => {
|
||||||
|
return path.split(".").reduce<unknown>((value, key) => {
|
||||||
|
if (typeof value !== "object" || value === null || !Object.hasOwn(value, key)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (value as Record<string, unknown>)[key];
|
||||||
|
}, profile);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const extractProfileName = (profile: Profile): string | undefined => {
|
||||||
|
if (!env.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE) {
|
||||||
|
// Use the name as the username if the preferred_username is an email address
|
||||||
|
return (profile.preferred_username?.includes("@") ? profile.name : profile.preferred_username) ?? undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const profileName = getProfileValueByPath(profile, env.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE);
|
||||||
|
return typeof profileName === "string" ? profileName : undefined;
|
||||||
|
};
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import type { Profile } from "@auth/core/types";
|
||||||
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
const mockEnv = vi.hoisted(() => ({
|
||||||
|
AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE: undefined as string | undefined,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../../../env", () => ({ env: mockEnv }));
|
||||||
|
|
||||||
|
import { extractProfileName, getProfileValueByPath } from "../profile";
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
mockEnv.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getProfileValueByPath", () => {
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
resource_access: {
|
||||||
|
homarr: {
|
||||||
|
roles: ["admins"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
test("returns a top-level claim", () => {
|
||||||
|
expect(getProfileValueByPath(profile, "sub")).toBe("user-id");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns a nested claim", () => {
|
||||||
|
expect(getProfileValueByPath(profile, "resource_access.homarr.roles")).toEqual(["admins"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns undefined when the path does not exist", () => {
|
||||||
|
expect(getProfileValueByPath(profile, "resource_access.missing.roles")).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("extractProfileName", () => {
|
||||||
|
test("uses preferred_username when overwrite is not set", () => {
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
preferred_username: "johndoe",
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBe("johndoe");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("uses name when preferred_username is an email", () => {
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
preferred_username: "john@example.com",
|
||||||
|
name: "John Doe",
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBe("John Doe");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns undefined when the fallback name is null", () => {
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
preferred_username: "john@example.com",
|
||||||
|
name: null,
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns undefined when preferred_username is missing", () => {
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("uses a nested name claim when configured", () => {
|
||||||
|
mockEnv.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE = "user.profile.display_name";
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
user: { profile: { display_name: "Nested User" } },
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBe("Nested User");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns undefined when the configured claim is not a string", () => {
|
||||||
|
mockEnv.AUTH_OIDC_NAME_ATTRIBUTE_OVERWRITE = "user.profile";
|
||||||
|
const profile = {
|
||||||
|
sub: "user-id",
|
||||||
|
user: { profile: { display_name: "Nested User" } },
|
||||||
|
} satisfies Profile;
|
||||||
|
|
||||||
|
expect(extractProfileName(profile)).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";
|
import type { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";
|
||||||
import type { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
|
import type { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { describe, expect, test, vi } from "vitest";
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
@@ -21,6 +21,12 @@ vi.mock("../env", () => {
|
|||||||
env: mockEnv,
|
env: mockEnv,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
mockEnv.AUTH_OIDC_GROUPS_ATTRIBUTE = "someRandomGroupsKey";
|
||||||
|
mockEnv.AUTH_OIDC_GROUPS_LOCAL_MANAGEMENT = false;
|
||||||
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||||
type HeadersExport = typeof import("next/headers");
|
type HeadersExport = typeof import("next/headers");
|
||||||
vi.mock("next/headers", async (importOriginal) => {
|
vi.mock("next/headers", async (importOriginal) => {
|
||||||
@@ -152,6 +158,30 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
expect(dbGroupMembers?.groupId).toBe("1");
|
expect(dbGroupMembers?.groupId).toBe("1");
|
||||||
});
|
});
|
||||||
|
test("should add missing group membership from a nested claim", async () => {
|
||||||
|
// Arrange
|
||||||
|
mockEnv.AUTH_OIDC_GROUPS_ATTRIBUTE = "resource_access.homarr.roles";
|
||||||
|
const db = createDb();
|
||||||
|
await createUserAsync(db, "oidc");
|
||||||
|
await createGroupAsync(db);
|
||||||
|
const eventHandler = createSignInEventHandler(db);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await eventHandler?.({
|
||||||
|
user: { id: "1", name: "test" },
|
||||||
|
profile: {
|
||||||
|
preferred_username: "test",
|
||||||
|
resource_access: { homarr: { roles: ["test"] } },
|
||||||
|
},
|
||||||
|
account: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
const dbGroupMembers = await db.query.groupMembers.findFirst({
|
||||||
|
where: eq(groupMembers.userId, "1"),
|
||||||
|
});
|
||||||
|
expect(dbGroupMembers?.groupId).toBe("1");
|
||||||
|
});
|
||||||
test("should remove group membership", async () => {
|
test("should remove group membership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = createDb();
|
||||||
|
|||||||
Reference in new issue
Block a user