From eb35081bf744250256d5ccd227cd2c5b2e4fdf3a Mon Sep 17 00:00:00 2001 From: axherrm Date: Fri, 8 Dec 2023 22:48:40 +0100 Subject: [PATCH] add CD for all branches --- .github/workflows/continuous-deployment.yml | 100 ++++++++++++++++---- .github/workflows/index.html | 16 ++++ 2 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/index.html diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index f64ac7a..b5a2788 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -1,4 +1,4 @@ -name: Continous Deployment +name: Continuous Deployment on: push: @@ -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: @@ -21,6 +22,8 @@ jobs: runs-on: ubuntu-latest outputs: branches: ${{ steps.generate-matrix.outputs.branches }} + json_branches: ${{ steps.generate-matrix.outputs.json_branches }} + artifact_names: ${{ steps.generate-matrix.outputs.artifact_names }} steps: - uses: actions/checkout@v4 with: @@ -32,8 +35,15 @@ jobs: 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} + echo "branches=${branches}" >> $GITHUB_OUTPUT + echo "json_branches=${json_branches}" >> $GITHUB_OUTPUT + branch_count=$(git branch -r | wc -l) + artifact_names="" + for ((i = 0; i < $branch_count; i++)) + do + artifact_names+="-n ${i} " + done + echo "artifact_names=${artifact_names}" >> $GITHUB_OUTPUT my_echo: runs-on: ubuntu-latest @@ -50,7 +60,7 @@ 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: @@ -65,6 +75,10 @@ jobs: 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 \ @@ -73,21 +87,65 @@ jobs: -# 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 + 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 +# - uses: actions/download-artifact@master # with: -# path: ./dist/cv/browser/ -# - name: Deploy to GitHub Pages -# id: deployment -# uses: actions/deploy-pages@v2 +# name: my-artifact +# path: path/to/artifact + +# - name: Download multiple artifacts +# uses: marcofaggian/action-download-multiple-artifacts@v4.0.1 +# with: +# names: ${{ needs.build_matrix.outputs.artifact_names }} +# paths: ${{ needs.build_matrix.outputs.branches }} +# workflow: continuous-deployment.yml +# - run: | +# workflow_run_id=$(echo "${GITHUB_RUN_ID}") +# echo "Die Workflow-Ausführungs-ID lautet: $workflow_run_id" + - run: gh run download ${{ vars.GITHUB_RUN_ID }} --dir branches + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# RUN_ID: ${{ vars.GITHUB_RUN_ID }} + + - name: Create public folder + run: | + mkdir public + mv .github/workflows/index.html ./public/index.html + cd public + json_branches='${{ needs.build_matrix.outputs.json_branches }}' + branches=$(echo "$json_branches" | jq -r '.[]') + echo $branches + i=0 + for branch in ${branches} + do + mkdir -p -- $branch + mv ../branches/$i ./$branch + + echo "
  • ${branch}
  • " >> index.html + + i=$((i+1)) + done + ls -lR +# sed -i '' -e '/