Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/linux-flatpak-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
name: Linux Flatpak Comment
on:
workflow_run:
workflows: ["Linux Flatpak Package"]
types: [completed]

jobs:
comment-flatpak:
name: Create a comment with a link to the built Flatpak
runs-on: ubuntu-latest
if: |-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Comment Flatpak
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Discover the origin pull request ID.
// Since GitHub does not include any pull requests from forks as part of a WorkflowRun we need to look up the PR ourselves.
const pullRequestsForThisBranch = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.payload.workflow_run.head_repository.owner.login,
repo: context.payload.workflow_run.head_repository.name,
commit_sha: context.payload.workflow_run.head_branch,
});
const latestPullRequest = pullRequestsForThisBranch.data.sort((a, b) => b.id - a.id)[0];
if (!latestPullRequest) {
console.log("Could not find recent pull request related to this workflow run");
return;
};
const prId = latestPullRequest.number;
console.log(`Discovered pull request #${prId}`);

const workflowArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const artifact = workflowArtifacts.data.artifacts.filter((artifact) => artifact.name == "com.nextcloud.desktopclient.nextcloud.flatpak")[0];

if (!artifact) {
console.log("Could not find matching artifact");
return;
}

// artifact.url and artifact.archive_download_url contain a URL that's supposed to be used by API clients only
const artifactUrl = `https://github.com/nextcloud/desktop/actions/runs/${artifact.workflow_run.id}/artifacts/${artifact.id}`;

const comment_identifier_string = "<!-- automated comment for a flatpak build -->";

const comment_body = `
${comment_identifier_string}

Artifact containing the Flatpak bundle: [${artifact.name}.zip](${artifactUrl})

Digest: \`${artifact.digest}\`

To test this change/fix you can download the above artifact file, unzip it, and install the bundle with:
\`flatpak install --user ${artifact.name}\`

Please make sure to quit your existing Nextcloud app and backup your data.
`;

console.log("fetching old comments")
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prId,
});

comments
.data
.filter(comment => comment.body?.includes(comment_identifier_string))
.forEach(comment => {
console.log(`deleting previous Flatpak comment with ID ${comment.id}`)
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
})
});

console.log("creating new comment")
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prId,
body: comment_body,
});
28 changes: 28 additions & 0 deletions .github/workflows/linux-flatpak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
name: Linux Flatpak Package
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, closed]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
flatpak:
if: ${{ github.event.action != 'closed' && !github.event.pull_request.draft }}
name: Linux Flatpak Package
runs-on: ubuntu-latest
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-48
options: --privileged
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: flatpak/flatpak-github-actions/flatpak-builder@79327416609af08178ad73b352877e51450790b3 # v6.8
with:
bundle: com.nextcloud.desktopclient.nextcloud.flatpak
manifest-path: admin/linux/flatpak/com.nextcloud.desktopclient.nextcloud.yml
upload-artifact: true
artifact-name: com.nextcloud.desktopclient.nextcloud.flatpak
build-bundle: true
Loading
Loading