Skip to content

Commit

Permalink
add CD for all branches
Browse files Browse the repository at this point in the history
  • Loading branch information
axherrm committed Dec 10, 2023
1 parent 62744d2 commit 2567f3e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 36 deletions.
87 changes: 51 additions & 36 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continous Deployment
name: Continuous Deployment

on:
push:
Expand All @@ -10,6 +10,7 @@ permissions:
contents: read
pages: write
id-token: write
actions: read

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
Expand All @@ -20,28 +21,17 @@ jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.generate-matrix.outputs.branches }}
json_branches: ${{ steps.generate-matrix.outputs.json_branches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v2.1.0
- name: Generate Matrix
id: generate-matrix
run: |
branches=($(git branch -r | cut -c 3- | sed 's/origin\///g'))
json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .)
echo "branches=${json_branches}" >> $GITHUB_OUTPUT
# echo ::set-output name=branches::${json_branches}

my_echo:
runs-on: ubuntu-latest
needs:
- build_matrix
steps:
- name: Echo previous outputs
run: echo "${{ toJSON(needs.build_matrix.outputs) }}"
echo "json_branches=${json_branches}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
Expand All @@ -50,44 +40,69 @@ jobs:
- build_matrix
strategy:
matrix:
branch: ${{ fromJSON(needs.build_matrix.outputs.branches) }}
branch: ${{ fromJSON(needs.build_matrix.outputs.json_branches) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- uses: actions/setup-node@v4
with:
# Version Spec of the version to use in SemVer notation.
# It also emits such aliases as lts, latest, nightly and canary builds
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
node-version: 20
- name: Build
run: |
npm install
npm run build
- uses: actions/upload-artifact@v3
with:
name: ${{ strategy.job-index }}
path: dist/cv/browser/
# - name: Build
# run: |
# git for-each-ref --shell \
# --format='git checkout \
# refs/heads/

deploy:
runs-on: ubuntu-latest
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs:
- build_matrix
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v3
- run: gh run download ${{ vars.GITHUB_RUN_ID }} --dir branches
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create public folder
run: |
mkdir public
mv .github/workflows/index.html ./public/index.html
cd public
branches=$(echo '${{ needs.build_matrix.outputs.json_branches }}' | jq -r '.[]')
i=0
for branch in ${branches}
do
mkdir -p -- $branch
mv ../branches/$i/* ./$branch
echo "<li><a href=\"./CV/${branch}\">${branch}</a></li>" >> index.html
# deploy:
# runs-on: ubuntu-latest
# name: Deploy
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# needs:
# - build
# steps:
# - name: Setup Pages
# uses: actions/configure-pages@v3
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v2
# with:
# path: ./dist/cv/browser/
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v2
i=$((i+1))
done
cat ../.github/workflows/index_suffix.html >> index.html
ls -lR
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./public/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
12 changes: 12 additions & 0 deletions .github/workflows/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CV</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<h1>CV - Branches</h1>
<ul id="list">
3 changes: 3 additions & 0 deletions .github/workflows/index_suffix.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
</ul>
</body>
</html>

0 comments on commit 2567f3e

Please sign in to comment.