|
1 | | -# Workflow for building and deploying an Astro site to GitHub Pages |
2 | | -# plus inclusion du site statique de la branche `old` dans /old |
3 | | - |
4 | | -name: Deploy Astro + Old site to GitHub Pages |
| 1 | +name: Deploy Vue.js app to GitHub Pages |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | push: |
8 | | - branches: ["master"] |
| 5 | + branches: |
| 6 | + - vue # Déploie quand tu pousses sur la branche 'vue' |
9 | 7 | workflow_dispatch: |
10 | 8 |
|
11 | 9 | permissions: |
12 | 10 | contents: read |
13 | 11 | pages: write |
14 | 12 | id-token: write |
15 | 13 |
|
16 | | -concurrency: |
17 | | - group: "pages" |
18 | | - cancel-in-progress: false |
19 | | - |
20 | | -env: |
21 | | - BUILD_PATH: "." # dossier du site Astro |
22 | | - |
23 | 14 | jobs: |
24 | 15 | build: |
25 | | - name: Build Astro site + include old version |
26 | 16 | runs-on: ubuntu-latest |
| 17 | + |
27 | 18 | steps: |
28 | | - - name: Checkout master (Astro site) |
| 19 | + - name: Checkout repository |
29 | 20 | uses: actions/checkout@v4 |
30 | | - with: |
31 | | - ref: master |
32 | | - |
33 | | - - name: Detect package manager |
34 | | - id: detect-package-manager |
35 | | - run: | |
36 | | - if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
37 | | - echo "manager=yarn" >> $GITHUB_OUTPUT |
38 | | - echo "command=install" >> $GITHUB_OUTPUT |
39 | | - echo "runner=yarn" >> $GITHUB_OUTPUT |
40 | | - echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT |
41 | | - elif [ -f "${{ github.workspace }}/package.json" ]; then |
42 | | - echo "manager=npm" >> $GITHUB_OUTPUT |
43 | | - echo "command=ci" >> $GITHUB_OUTPUT |
44 | | - echo "runner=npx --no-install" >> $GITHUB_OUTPUT |
45 | | - echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT |
46 | | - else |
47 | | - echo "Unable to determine package manager" |
48 | | - exit 1 |
49 | | - fi |
50 | 21 |
|
51 | | - - name: Setup Node |
| 22 | + - name: Setup Node.js |
52 | 23 | uses: actions/setup-node@v4 |
53 | 24 | with: |
54 | | - node-version: "20" |
55 | | - cache: ${{ steps.detect-package-manager.outputs.manager }} |
56 | | - cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }} |
57 | | - |
| 25 | + node-version: 18 # Compatible avec Vue 3/Vite |
| 26 | + |
58 | 27 | - name: Setup Pages |
59 | 28 | id: pages |
60 | 29 | uses: actions/configure-pages@v5 |
61 | | - |
| 30 | + |
62 | 31 | - name: Install dependencies |
63 | | - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
64 | | - working-directory: ${{ env.BUILD_PATH }} |
65 | | - |
66 | | - - name: Build Astro site |
67 | | - run: | |
68 | | - ${{ steps.detect-package-manager.outputs.runner }} astro build \ |
69 | | - --site "${{ steps.pages.outputs.origin }}" \ |
70 | | - --base "${{ steps.pages.outputs.base_path }}" |
71 | | - working-directory: ${{ env.BUILD_PATH }} |
72 | | - |
73 | | - - name: Clone old branch (static site) |
74 | | - run: | |
75 | | - git clone --depth 1 --branch old https://github.com/${{ github.repository }} tmp-old |
76 | | - mkdir -p ${{ env.BUILD_PATH }}/dist/old |
77 | | - cp -r tmp-old/* ${{ env.BUILD_PATH }}/dist/old/ || true |
78 | | - rm -rf tmp-old |
| 32 | + run: npm install |
79 | 33 |
|
| 34 | + - name: Build project |
| 35 | + run: npm run build |
| 36 | + |
80 | 37 | - name: Upload artifact |
81 | 38 | uses: actions/upload-pages-artifact@v3 |
82 | 39 | with: |
83 | | - path: ${{ env.BUILD_PATH }}/dist |
| 40 | + path: ./dist |
84 | 41 |
|
85 | 42 | deploy: |
86 | | - name: Deploy to GitHub Pages |
| 43 | + needs: build |
| 44 | + runs-on: ubuntu-latest |
87 | 45 | environment: |
88 | 46 | name: github-pages |
89 | 47 | url: ${{ steps.deployment.outputs.page_url }} |
90 | | - needs: build |
91 | | - runs-on: ubuntu-latest |
92 | 48 | steps: |
93 | 49 | - name: Deploy to GitHub Pages |
94 | 50 | id: deployment |
|
0 commit comments