# This is a basic workflow to help you get started with Actions

name: CI flatpak

# Controls when the action will run. 
on:
  # Trigger the workflow if we merged into develop or if we create a release
  # Since the workflow takes significantly longer (because of the ffmpeg build) we want to execute 
  # this as little as possible.
  push:
    branches: [ develop ]
  release:
    branches: [ develop ]
    types:
      - created
        
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  flatpak-builder:
    name: "Flatpak Builder"
    runs-on: ubuntu-latest
    container:
      image: docker.io/bilelmoussaoui/flatpak-github-actions
      options: --privileged
    steps:
    - uses: actions/checkout@v2
    - uses: bilelmoussaoui/flatpak-github-actions@v2
      with:
        bundle: "YUView.flatpak"
        manifest-path: "de.rwth_aachen.ient.YUView.yaml"
    - name: Upload Release
      uses: actions/upload-release-asset@v1.0.1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ github.event.release.upload_url }}
        asset_path: YUView.flatpak
        asset_name: YUView.flatpak
        asset_content_type: application/zip
      if: github.event_name == 'release' 
