Merge pull request #166 from retejs/update-eslint #204
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Detect package manager | |
id: detect-package-manager | |
run: | | |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
echo "manager=yarn" >> $GITHUB_OUTPUT | |
echo "command=install" >> $GITHUB_OUTPUT | |
exit 0 | |
elif [ -f "${{ github.workspace }}/package.json" ]; then | |
echo "manager=npm" >> $GITHUB_OUTPUT | |
echo "command=ci" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "Unable to determine packager manager" | |
exit 1 | |
fi | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: ${{ steps.detect-package-manager.outputs.manager }} | |
- name: Restore cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
dist | |
.nuxt | |
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} | |
restore-keys: | | |
${{ runner.os }}-nuxt-build- | |
- name: Install dependencies | |
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} | |
- name: Export diagrams | |
run: ${{ steps.detect-package-manager.outputs.manager }} run update-diagrams:ci | |
- name: Static HTML export with Nuxt | |
run: ${{ steps.detect-package-manager.outputs.manager }} run generate | |
env: | |
GTAG_ID: ${{ vars.GTAG_ID }} | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: ./dist | |
deploy: | |
name: Publish to GitHub Pages | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
deploy-cloudflare: | |
name: Publish to Cloudflare Pages | |
environment: | |
name: cloudflare-pages | |
url: ${{ steps.deployment.outputs.url }} | |
permissions: | |
contents: read | |
deployments: write | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: github-pages | |
path: . | |
- name: Untar | |
run: | | |
mkdir -p dist | |
tar -xvf artifact.tar --directory dist | |
- name: Publish to Cloudflare Pages | |
id: deployment | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ vars.CLOUDFLARE_ID }} | |
projectName: retejs | |
directory: ./dist | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
wranglerVersion: '3' |