Skip to content

Potato4

Potato4 #68

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
schedule:
# Run every 6 days to help us stay on our toes
- cron: '0 0 */6 * *'
# Required for write permission in a PR
pull_request_target:
branches: ["master"]
permissions:
id-token: write
pages: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt install -y xvfb
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run bun
run: |
bun install --frozen-lockfile
bun run lint
bun run typecheck
bun run build
xvfb-run --auto-servernum bun test:ci
deploy-page:
environment:
name: 'Pages Preview'
url: ${{ steps.preview_deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run bun
run: |
bun install --frozen-lockfile
bun run build
# This will be used by the deployment PR action
cp -r dist ./_site
- name: Deploy 🚀
uses: JamesIves/[email protected]
if: github.event_name != 'pull_request'
with:
branch: gh-pages
folder: dist
- name: Setup Pages
if: github.event_name == 'pull_request'
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- name: Upload artifact for preview
if: github.event_name == 'pull_request'
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
- name: Deploy PR preview 🚀
id: preview_deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
if: github.event_name == 'pull_request'
with:
preview: 'true'
deploy-electron:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-13
suffix: macos
extension: dmg
- os: ubuntu-latest
suffix: linux
extension: AppImage
- os: windows-latest
suffix: windows
extension: exe
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Build electron
run: |
bun install --frozen-lockfile
bun run build
bun deploy:electron
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: cockpit-${{ matrix.suffix }}
path: dist/Cockpit*.${{ matrix.extension }}
if-no-files-found: error
- name: Upload Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Cockpit*.${{ matrix.extension }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
deploy-flatpak:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install flatpak
run: |
sudo apt update
sudo apt install -y --fix-missing flatpak flatpak-builder
sudo flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo || true
- name: Build electron
run: |
bun install --frozen-lockfile
bun run build
env DEBUG="@malept/flatpak-bundler" bun deploy:flatpak
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: cockpit-flatpak
path: dist/Cockpit*.flatpak
if-no-files-found: error
- name: Upload Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Cockpit*.flatpak
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
deploy-blueos-extension:
needs: test
runs-on: ubuntu-latest
env:
PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
steps:
- name: Login to Docker Hub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Build cockpit
run: |
bun install --frozen-lockfile
bun run build
- name: Prepare
id: prepare
run: |
# Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
# If git tag matches semver, append latest tag to the push.
DOCKER_IMAGE=${DOCKER_USERNAME:-bluerobotics}/cockpit
VERSION=${GITHUB_REF##*/}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "buildx_args=${TAGS} --file Dockerfile ." >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Docker Buildx (build)
run: |
docker buildx build \
--output "type=image,push=false" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build \
--output "type=image,push=true" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools \
inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}