Skip to content

Commit

Permalink
Add CI/CD files for building the plugin
Browse files Browse the repository at this point in the history
* Build and publish the base arch linux image every midnight
* Build the plugin on every PR and push to main, and every night at 2AM
  • Loading branch information
zjeffer authored and Duckonaut committed Apr 27, 2024
1 parent 22b6d0d commit 44ec4e8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM archlinux:latest

# Update the package repositories and install sudo
RUN pacman -Syu --noconfirm --needed sudo git base-devel

# Create a new user
RUN useradd -m user && \
passwd -d user && \
printf 'user ALL=(ALL) ALL\n' | tee -a /etc/sudoers

# Switch to the new user so makepkg doesn't run as root
USER user
WORKDIR /home/user

# Install paru package manager
RUN git clone https://aur.archlinux.org/paru.git && \
cd paru && \
makepkg -si --noconfirm

WORKDIR /app

USER root

# Define the command to run your application
CMD ["/bin/bash"]
28 changes: 28 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Push Docker Image

on:
schedule:
# run every night at midnight
- cron: '0 0 * * *'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .github/Dockerfile
push: true
tags: duckonaut/hyprland-arch:latest
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
# run every night at 2AM (the base docker image is updated at midnight)
- cron: '0 2 * * *'

jobs:
build:
runs-on: ubuntu-latest
container:
# image built from the Dockerfile in the .github/ folder
image: duckonaut/hyprland-arch:latest
steps:
- name: Install dependencies
# TODO: remove hyprwayland-scanner-git once hyprland-git properly depends on it
run: |
sudo -u user sh -c "paru -Syu --noconfirm hyprwayland-scanner-git hyprland-git"
- name: Checkout current repository
uses: actions/checkout@v4

- name: Build current repository
run: |
meson setup build --wipe
ninja -C build

0 comments on commit 44ec4e8

Please sign in to comment.