From f29a6149720a907feebceba5ab5b1b9d8312418c Mon Sep 17 00:00:00 2001 From: axherrm Date: Fri, 8 Dec 2023 21:04:49 +0100 Subject: [PATCH 1/4] add CD for all branches --- .github/workflows/continuous-deployment.yml | 100 ++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/continuous-deployment.yml diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml new file mode 100644 index 0000000..2f017d4 --- /dev/null +++ b/.github/workflows/continuous-deployment.yml @@ -0,0 +1,100 @@ +name: Continous Deployment + +on: + push: + branches: + - "**" + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build_matrix: + runs-on: ubuntu-latest + outputs: + branches: ${{ steps.generate-matrix.outputs.branches }} +# versions: ${{ steps.generate-matrix.outputs.versions }} + steps: + - uses: actions/checkout@v4 +# with: +# fetch-depth: 0 + - name: Generate Matrix + id: generate-matrix + run: | + apt-get update + apt-get install -y jq + branches=($(git branch | cut -c 3-)) + json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .) +# json_branches=$(toJSON "${branches[@]}") + echo ::set-output name=branches::${json_branches} + # SERVICES='${{ toJSON(github.event.client_payload.services) }}' +# echo ::set-output name=services::${SERVICES} +# VERSIONS='${{ toJSON(github.event.client_payload.versions) }}' +# echo ::set-output name=versions::${VERSIONS} + # ------------------------ + my_echo: + runs-on: ubuntu-latest + needs: + - build_matrix + steps: + - name: Echo previous outputs + run: echo "${{ toJSON(needs.build_matrix.outputs) }}" + + build: + runs-on: ubuntu-latest + name: Build + needs: + - build_matrix + strategy: + matrix: + branch: ${{ fromJSON(needs.build_matrix.outputs.branches) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + # with: +# fetch-depth: 0 + - 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 +# - 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 +# 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 From 62744d2193d5a07cd76df7ad5c128bd0b5038619 Mon Sep 17 00:00:00 2001 From: axherrm Date: Fri, 8 Dec 2023 21:42:50 +0100 Subject: [PATCH 2/4] add CD for all branches --- .github/workflows/continuous-deployment.yml | 23 +++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 2f017d4..f64ac7a 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -21,25 +21,20 @@ jobs: runs-on: ubuntu-latest outputs: branches: ${{ steps.generate-matrix.outputs.branches }} -# versions: ${{ steps.generate-matrix.outputs.versions }} steps: - uses: actions/checkout@v4 -# with: -# fetch-depth: 0 + with: + fetch-depth: 0 + - name: 'Setup jq' + uses: dcarbone/install-jq-action@v2.1.0 - name: Generate Matrix id: generate-matrix run: | - apt-get update - apt-get install -y jq - branches=($(git branch | cut -c 3-)) + branches=($(git branch -r | cut -c 3- | sed 's/origin\///g')) json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .) -# json_branches=$(toJSON "${branches[@]}") - echo ::set-output name=branches::${json_branches} - # SERVICES='${{ toJSON(github.event.client_payload.services) }}' -# echo ::set-output name=services::${SERVICES} -# VERSIONS='${{ toJSON(github.event.client_payload.versions) }}' -# echo ::set-output name=versions::${VERSIONS} - # ------------------------ + echo "branches=${json_branches}" >> $GITHUB_OUTPUT +# echo ::set-output name=branches::${json_branches} + my_echo: runs-on: ubuntu-latest needs: @@ -60,8 +55,6 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ matrix.branch }} - # with: -# fetch-depth: 0 - uses: actions/setup-node@v4 with: # Version Spec of the version to use in SemVer notation. From 2567f3edf5b8ff48cefa87c23e2e1121f597c790 Mon Sep 17 00:00:00 2001 From: axherrm Date: Fri, 8 Dec 2023 22:48:40 +0100 Subject: [PATCH 3/4] add CD for all branches --- .github/workflows/continuous-deployment.yml | 87 ++++++++++++--------- .github/workflows/index.html | 12 +++ .github/workflows/index_suffix.html | 3 + 3 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/index.html create mode 100644 .github/workflows/index_suffix.html diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index f64ac7a..7fbbf95 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: @@ -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 @@ -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 "
  • ${branch}
  • " >> 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 diff --git a/.github/workflows/index.html b/.github/workflows/index.html new file mode 100644 index 0000000..4aff2e3 --- /dev/null +++ b/.github/workflows/index.html @@ -0,0 +1,12 @@ + + + + + CV + + + + + +

    CV - Branches

    +
      diff --git a/.github/workflows/index_suffix.html b/.github/workflows/index_suffix.html new file mode 100644 index 0000000..c00eaa4 --- /dev/null +++ b/.github/workflows/index_suffix.html @@ -0,0 +1,3 @@ +
    + + From c5ff1376247eae8954877c14f3e2ca1b0c512779 Mon Sep 17 00:00:00 2001 From: axherrm Date: Sun, 10 Dec 2023 13:45:36 +0100 Subject: [PATCH 4/4] fix build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31b37bc..81f8eb0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ng build", + "build": "ng build --base-href='./'", "watch": "ng build --watch --configuration development", "test": "ng test" },