From 65dac6fe726d2fc60abbb1938f0a48a97d76642a Mon Sep 17 00:00:00 2001 From: alexandre artus Date: Mon, 15 Jul 2024 16:05:26 +0200 Subject: [PATCH] put a directory by default in upload --- .github/workflows/build-and-deploy.yml | 46 ++++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 727a9df4..cc65c108 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,6 +1,6 @@ name: Optimize map and deploy -on: [ push ] +on: [push] permissions: contents: write @@ -17,8 +17,8 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' + node-version: "18.x" + registry-url: "https://registry.npmjs.org" - name: "Install dependencies" run: npm install @@ -26,15 +26,39 @@ jobs: - name: "Build scripts" run: npm run build - - name: Deploy + - name: Use API key from secrets + env: + MAP_STORAGE_API_KEY: ${{ secrets.MAP_STORAGE_API_KEY }} + run: echo "MAP_STORAGE_API_KEY=${MAP_STORAGE_API_KEY}" >> $GITHUB_ENV + + - name: Use URL Map STORAGE from secrets + env: + MAP_STORAGE_URL: ${{ secrets.MAP_STORAGE_URL }} + run: echo "MAP_STORAGE_URL=${MAP_STORAGE_URL}" >> $GITHUB_ENV + + - name: Generate .env.secret + run: echo "MAP_STORAGE_API_KEY=${{ secrets.MAP_STORAGE_API_KEY }}" > .env.secret + + - name: Extract UPLOAD_MODE from .env + run: echo "UPLOAD_MODE=$(grep '^[^#]*UPLOAD_MODE' .env | cut -d '=' -f2)" >> $GITHUB_ENV + + - name: Extract and format repository info + run: echo "DIRECTORY=${{ github.actor }}-${{ github.event.repository.name }}" >> $GITHUB_ENV + + - name: Create or update .env file + run: | + REPO_INFO="${{ github.actor }}-${{ github.event.repository.name }}" + echo "DIRECTORY=${REPO_INFO}" > .env.tmp + + - name: Deploy in MAP STORAGE + if: ${{ env.UPLOAD_MODE == 'MAP_STORAGE' }} + run: npm run upload-only + + - name: Deploy on GITHUB PAGES + if: ${{ env.UPLOAD_MODE == 'GH_PAGES' }} uses: JamesIves/github-pages-deploy-action@releases/v3 - if: github.ref == 'refs/heads/master' with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: dist/ # The folder the action should deploy. + BRANCH: gh-pages + FOLDER: dist/ BASE_BRANCH: master - - - name: Bash2 - run: | - ls -al