Use anchors & aliases in GH actions

Reduces code duplication
This commit is contained in:
fosslinux 2023-12-26 16:23:38 +11:00
parent fe9cb1222f
commit 75991632fb

View file

@ -2,6 +2,7 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
---
name: Run under bubblewrap name: Run under bubblewrap
on: on:
@ -16,35 +17,42 @@ jobs:
name: Run up to Linux build under bubblewrap name: Run up to Linux build under bubblewrap
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install bubblewrap - &install-bubblewrap
name: Install bubblewrap
run: sudo apt install bubblewrap run: sudo apt install bubblewrap
- name: Checkout repo - &checkout-repo
name: Checkout repo &checkout-repo
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
# There is a strange bug(?) in nongnu, when you clone a git repository # There is a strange bug(?) in nongnu, when you clone a git repository
# against a commit != HEAD with depth=1, it errors out. # against a commit != HEAD with depth=1, it errors out.
fetch-depth: 0 fetch-depth: 0
- name: Query cache for sources - &query-sources
name: Query cache for sources
id: cache id: cache
uses: actions/cache/restore@v3 uses: actions/cache/restore@v3
with: with:
path: | path: |
distfiles distfiles
key: cache-${{ hashFiles('steps/*/sources') }} key: cache-${{ hashFiles('steps/*/sources') }}
- name: Get sources - &get-sources
name: Get sources
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
run: ./download-distfiles.sh run: ./download-distfiles.sh
- name: Cache sources - &cache-sources
name: Cache sources
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3 uses: actions/cache/save@v3
with: with:
path: | path: |
distfiles distfiles
key: cache-${{ hashFiles('steps/*/sources') }} key: cache-${{ hashFiles('steps/*/sources') }}
- name: Run bootstrap - &run-bootstrap
name: Run bootstrap
run: ./rootfs.py --bwrap --external-sources --build-kernels --preserve --cores 2 --internal-ci pass1 run: ./rootfs.py --bwrap --external-sources --build-kernels --preserve --cores 2 --internal-ci pass1
- name: Archive created packages - &archive-packages
name: Archive created packages
if: failure() # archive failed builds progress if: failure() # archive failed builds progress
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
@ -63,46 +71,19 @@ jobs:
needs: pass1 needs: pass1
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install bubblewrap - *install-bubblewrap
run: sudo apt install bubblewrap - *checkout-repo
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: recursive
# There is a strange bug(?) in nongnu, when you clone a git repository
# against a commit != HEAD with depth=1, it errors out.
fetch-depth: 0
- name: Get pass1_image - name: Get pass1_image
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: internal_pass1_image name: internal_pass1_image
- name: Extract pass1_image - name: Extract pass1_image
run: tar -xf pass1_image.tar run: tar -xf pass1_image.tar
- name: Query cache for sources - *query-sources
id: cache - *get-sources
uses: actions/cache/restore@v3 - *cache-sources
with: - *run-bootstrap
path: | - *archive-packages
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Get sources
if: steps.cache.outputs.cache-hit != 'true'
run: ./download-distfiles.sh
- name: Cache sources
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Run bootstrap
run: ./rootfs.py --bwrap --external-sources --build-kernels --preserve --cores 2 --internal-ci pass2
- name: Archive created packages
if: failure() # archive failed builds progress
uses: actions/upload-artifact@v3
with:
name: internal_packages_pass2
path: tmp/external/repo/**
- name: Tar pass2 image - name: Tar pass2 image
run: tar -cf pass2_image.tar tmp run: tar -cf pass2_image.tar tmp
- name: Archive pass2_image - name: Archive pass2_image
@ -116,43 +97,17 @@ jobs:
needs: pass2 needs: pass2
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install bubblewrap - *install-bubblewrap
run: sudo apt install bubblewrap - *checkout-repo
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: recursive
# There is a strange bug(?) in nongnu, when you clone a git repository
# against a commit != HEAD with depth=1, it errors out.
fetch-depth: 0
- name: Get pass2_image - name: Get pass2_image
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: internal_pass2_image name: internal_pass2_image
- name: Extract pass2_image - name: Extract pass2_image
run: tar -xf pass2_image.tar run: tar -xf pass2_image.tar
- name: Query cache for sources - *query-sources
id: cache - *get-sources
uses: actions/cache/restore@v3 - *cache-sources
with: - *run-bootstrap
path: | - <<: *archive-packages
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Get sources
if: steps.cache.outputs.cache-hit != 'true'
run: ./download-distfiles.sh
- name: Cache sources
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Run bootstrap
run: ./rootfs.py --bwrap --external-sources --build-kernels --preserve --cores 2 --internal-ci pass3
- name: Archive created packages
if: always() # archive both failed and successful builds if: always() # archive both failed and successful builds
uses: actions/upload-artifact@v3
with:
name: packages
path: tmp/external/repo/**