Browse Source

Prevent GH Action from failing on removed branches (#136)

remove-git-dep
Aaron Dewes 4 years ago
committed by GitHub
parent
commit
9dcc7c6e76
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 61
      .github/workflows/pull_request.yml
  2. 22
      .github/workflows/push.yml

61
.github/workflows/pull_request.yml

@ -0,0 +1,61 @@
name: Build OS image on PR
on: [pull_request]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Run apt update
run: sudo apt update
- name: Install dependencies
run: sudo apt -y install quilt qemu-user-static debootstrap libarchive-tools jq
- name: Nuke current Docker installation
run: |
sudo systemctl stop docker
sudo apt-get purge docker-ce docker-ce-cli containerd.io moby-engine moby-cli
sudo rm -rf /var/lib/docker
- name: Re-install Docker
run: |
curl -fsSL https://get.docker.com | sudo sh
docker --version
- name: Enable experimental features in Docker
run: |
sudo rm -rf /etc/docker/daemon.json
echo '{"experimental": true}' | sudo tee -a /etc/docker/daemon.json
sudo systemctl restart docker
- name: Download Umbrel OS build scripts
run: |
git clone git://github.com/getumbrel/umbrel-os.git
- name: Setting env vars
env:
PR: ${{ github.event.number }}
run: |
UMBREL_OS_VERSION="dev"
IMAGE_NAME="umbrel-os-dev"
UMBREL_REPO="$(curl -s https://api.github.com/repos/getumbrel/umbrel/pulls/${PR} | jq .head.repo.clone_url | sed 's/"//g')"
UMBREL_BRANCH="$(curl -s https://api.github.com/repos/getumbrel/umbrel/pulls/${PR} | jq .head.ref | sed 's/"//g')"
echo "::set-env name=UMBREL_OS_VERSION::$UMBREL_OS_VERSION"
echo "::set-env name=IMAGE_NAME::$IMAGE_NAME"
echo "::set-env name=UMBREL_REPO::$UMBREL_REPO"
echo "::set-env name=UMBREL_BRANCH::$UMBREL_BRANCH"
- name: Build Umbrel OS
run: |
cd umbrel-os
echo "Building $IMAGE_NAME"
sudo IMG_FILENAME=$IMAGE_NAME ZIP_FILENAME=$IMAGE_NAME UMBREL_OS_VERSION=$UMBREL_OS_VERSION UMBREL_REPO=$UMBREL_REPO UMBREL_BRANCH=$UMBREL_BRANCH ./build.sh
cd ..
- name: Copy ZIP to current working dir
run: cp umbrel-os/deploy/*.zip ./
- name: Uploading artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ env.IMAGE_NAME }}.zip
name: ${{ env.IMAGE_NAME }}.zip

22
.github/workflows/main.yml → .github/workflows/push.yml

@ -1,6 +1,9 @@
name: Build OS image on push/PR
name: Build OS image of current master
on: [push]
on:
push:
branches:
- master
jobs:
build:
@ -8,11 +11,6 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- uses: jwalton/gh-find-current-pr@b6f8d7342efe4913388d5d1ac7f4b956caa5db52 # v1.0.2
id: findPr
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run apt update
run: sudo apt update
@ -47,16 +45,6 @@ jobs:
echo "::set-env name=IMAGE_NAME::$IMAGE_NAME"
echo "::set-env name=UMBREL_REPO::$UMBREL_REPO"
echo "::set-env name=UMBREL_BRANCH::$UMBREL_BRANCH"
- name: Setting env vars for PR
if: success() && steps.findPr.outputs.pr
env:
PR: ${{ steps.findPr.outputs.pr }}
run: |
echo "Building PR #${PR}"
UMBREL_REPO="$(curl https://api.github.com/repos/getumbrel/umbrel/pulls/${PR} | jq .head.repo.clone_url | sed 's/"//g')"
UMBREL_BRANCH="$(curl https://api.github.com/repos/getumbrel/umbrel/pulls/${PR} | jq .head.ref | sed 's/"//g')"
echo "::set-env name=UMBREL_REPO::$UMBREL_REPO"
echo "::set-env name=UMBREL_BRANCH::$UMBREL_BRANCH"
- name: Build Umbrel OS
run: |
Loading…
Cancel
Save