Skip to content

Commit

Permalink
flat-manager: Support profiles
Browse files Browse the repository at this point in the history
Add support for profiles, and add the 'flathub' profile.

Related: flatpak#64
  • Loading branch information
GeorgesStavracas committed Nov 23, 2021
1 parent a220602 commit 887f324
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 7 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,47 @@ jobs:
token: some_very_hidden_token
```

If you want to deploy to repositories that require validation, such as Flathub,
use the `profile` option:

```yaml
on:
push:
branches: [main]
name: Deploy
jobs:
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-40
options: --privileged
steps:
- uses: actions/checkout@v2
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
name: "Build"
with:
bundle: palette.flatpak
manifest-path: org.gnome.zbrown.Palette.yml
cache-key: flatpak-builder-${{ github.sha }}
mirror-screenshots-url: https://dl.flathub.org/repo/screenshots
- uses: bilelmoussaoui/flatpak-github-actions/flat-manager@v3
name: "Deploy"
with:
repository: beta
flat-manager-url: https://hub.flathub.org
token: some_very_hidden_token
profile: flathub
```

#### Inputs

| Name | Description | Required | Default |
| --- | ----------- | ----------- |----|
| `repository` | The repository to push the build into | Required | - |
| `flat-manager-url` | The flat-manager remote URL | Required | - |
| `token` | A flat-manager token | Required | - |
| `profile` | A profile to validate against. Accepted values: `flathub` | Optional | - |

### Docker Image

Expand Down
37 changes: 30 additions & 7 deletions flat-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@ const exec = require('@actions/exec')
// FIXME: get this from the outputs of the flatpak-builder action
const LOCAL_REPO_NAME = 'repo'

const run = (repository, flatManagerUrl, token) => {
exec.exec('flatpak', [
'build-update-repo',
'--generate-static-deltas',
LOCAL_REPO_NAME
])
const validateFlathubProfile = async (repository, flatManagerUrl, token) => {
// TODO
}

const PROFILES = {
'flathub': validateFlathubProfile,
}

const validateProfile = async (repository, flatManagerUrl, token, profile) => {
if (!profile)
return Promise.resolve()

if (!PROFILES[profile])
throw Error(`Unknown profile ${profile}`)

const validateFunc = PROFILES[profile]
return validateFunc(repository, flatManagerUrl, token)
}

const run = (repository, flatManagerUrl, token, profile) => {
validateProfile(repository, flatManagerUrl, token, profile)
.then(async () => {
await exec.exec('flatpak', [
'build-update-repo',
'--generate-static-deltas',
LOCAL_REPO_NAME
])
})
.then(async () => {
let buildId = ''
const exitCode = await exec.exec('flat-manager-client', [
Expand Down Expand Up @@ -60,6 +82,7 @@ if (require.main === module) {
run(
core.getInput('repository'),
core.getInput('flat-manager-url'),
core.getInput('token')
core.getInput('token'),
core.getInput('profile')
)
}

0 comments on commit 887f324

Please sign in to comment.