Skip to content

Commit daa2ee1

Browse files
committed
ci: Make ci.yaml valid for both pushes and prs
I didn't really see the reason to keep the files split, when ci.yaml is pretty easily made to work for both scenarios. We end up losing pushes pushing new container images for non-main branch builds if not created by dependabot. That was a lot to keep in context and also the correct thing to do. A push to a branch by someone with write permissions could end up pushing to quay and confusing things. So all in all we get better determenisitc behavior with this setup. Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
1 parent f09aba0 commit daa2ee1

File tree

2 files changed

+33
-61
lines changed

2 files changed

+33
-61
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: For each PR
1+
name: For each PR and Push
22
on:
33
pull_request:
44
paths-ignore:
55
- kernel/**
6+
push:
7+
paths-ignore:
8+
- kernel/**
69
jobs:
710
validation:
811
runs-on: ubuntu-20.04
@@ -16,7 +19,21 @@ jobs:
1619
- name: Set up Docker Buildx
1720
uses: docker/setup-buildx-action@v2
1821

19-
- uses: cachix/install-nix-action@v17
22+
- name: Login to quay.io
23+
if: github.ref == 'refs/heads/main'
24+
uses: docker/login-action@v1
25+
with:
26+
registry: quay.io
27+
username: ${{ secrets.QUAY_USERNAME }}
28+
password: ${{ secrets.QUAY_PASSWORD }}
29+
30+
- name: Figure Out Commit Short ID
31+
id: commitid
32+
run: |
33+
echo ::set-output name=short::$(git rev-parse --short HEAD)
34+
35+
- name: Install nix
36+
uses: cachix/install-nix-action@v17
2037
with:
2138
nix_path: nixpkgs=channel:nixos-unstable
2239

@@ -26,10 +43,20 @@ jobs:
2643
- name: Run formatters and linters
2744
run: nix-shell --run .github/workflows/formatters-and-linters.sh
2845

29-
- name: Build
30-
run: nix-shell --run 'make TAG=${{ github.sha }} dist'
46+
- name: Build Hook Tarballs
47+
run: nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} dist'
48+
49+
- name: Publish Hook
50+
if: github.ref == 'refs/heads/main'
51+
run: |
52+
# Build and push the container images
53+
nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} push'
54+
nix-shell --run 'make TAG=latest push'
55+
# Build and push the linuxkit images
56+
nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} deploy'
57+
nix-shell --run 'make TAG=latest deploy'
3158
3259
- uses: actions/upload-artifact@v3
3360
with:
34-
name: hook-${{ github.sha }}.tar.gz
35-
path: out/${{ github.sha }}/rel/hook-${{ github.sha }}.tar.gz
61+
name: hook-${{steps.commitid.outputs.short}}.tar.gz
62+
path: out/hook-${{steps.commitid.outputs.short}}.tar.gz

.github/workflows/push.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)