Merge pull request #23 from bboozzoo/bboozzoo/drop-houtro #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build repository and deploy | |
on: | |
push: | |
branches: [ "master" ] | |
workflow_dispatch: | |
inputs: | |
skip_upload: | |
required: false | |
description: "Skip upload" | |
type: boolean | |
default: false | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "deploy" | |
cancel-in-progress: false | |
env: | |
BASE_REPO_URL: https://bboozzoo.github.io/snapd-amazon-linux | |
jobs: | |
build-repo: | |
strategy: | |
matrix: | |
target: ["amazonlinux:2", "amazonlinux:2023"] | |
include: | |
- target: amazonlinux:2 | |
artifact_name: repo-tarball-amazonlinux-2 | |
repo_tarball_name: amazon-linux-2-repo.tar.xz | |
repo_url_suffix: amzn2 | |
- target: amazonlinux:2023 | |
artifact_name: repo-tarball-amazonlinux-2023 | |
repo_tarball_name: amazon-linux-2023-repo.tar.xz | |
repo_url_suffix: al2023 | |
runs-on: ubuntu-latest | |
container: ${{ matrix.target }} | |
steps: | |
- name: Install git | |
run: | | |
yum install git -y | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build repository artifacts | |
id: build-repo | |
uses: "./.github/actions/build-repo" | |
with: | |
target: ${{ matrix.target }} | |
repo_tarball_name: ${{ matrix.repo_tarball_name }} | |
repo_artifact_name: ${{ matrix.artifact_name }} | |
repo_url: ${{ env.BASE_REPO_URL }}/${{ matrix.repo_url_suffix }} | |
deploy: | |
needs: | |
- build-repo | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- uses: actions/download-artifact@v3 | |
- name: Prepare the artifacts | |
run: | | |
set -ex | |
find . -ls | |
mkdir -p repo/amzn2 repo/al2023 | |
tar -C repo/amzn2 --strip-components=1 -xvf repo-tarball-amazonlinux-2/amazon-linux-2-repo.tar.xz | |
tar -C repo/al2023 --strip-components=1 -xvf repo-tarball-amazonlinux-2023/amazon-linux-2023-repo.tar.xz | |
# generate index.html in each directory so that we can browse the paths | |
( | |
cd repo/ | |
LC_ALL=C find . -type d -print -exec sh -c 'tree "$0" \ | |
-H "." \ | |
-L 1 \ | |
--noreport \ | |
--dirsfirst \ | |
--charset utf-8 \ | |
-I "index.html" \ | |
--ignore-case \ | |
--timefmt "%d-%b-%Y %H:%M" \ | |
-s \ | |
-D \ | |
-o "$0/index.html"' {} \; | |
) | |
find repo/ -ls | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload entire repository | |
path: 'repo/' | |
- name: Deploy to GitHub Pages | |
# only on master or manual trigger | |
if: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && !inputs.skip_upload }} | |
id: deployment | |
uses: actions/deploy-pages@v4 |