From 9a245fbf136f4255dc928163ef05d2fb1b954b70 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 9 May 2021 13:34:39 +0200 Subject: [PATCH] Created new workflow to generate preview envs --- .github/workflows/deploy-preview.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 00000000..9cad6065 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,38 @@ +name: Deploy preview + +on: + pull_request: null + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use node.js 14.15 + uses: actions/setup-node@v1 + with: + node-version: 14.15 + - name: Build + run: | + npm ci && \ + npm install json && \ + node_modules/.bin/json -I -f package.json -e "this.homepage=\"/shlink-web-client/${{ steps.generate_slug.outputs.slug }}\"" && \ + npm run build + - name: Generate slug + id: generate_slug + run: echo "##[set-output name=slug;]$(echo ${GITHUB_REF#refs/heads/} | sed -r 's/[~\^]+//g' | sed -r 's/[^a-zA-Z0-9]+/-/g' | sed -r 's/^-+\|-+$//g' | tr A-Z a-z)" + - name: Deploy + uses: JamesIves/github-pages-deploy-action@4.1.1 + with: + branch: preview-env + folder: build + target-folder: ${{ steps.generate_slug.outputs.slug }} + - name: Publish env + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Preview environment + message: "**Preview environment**: https://shlinkio.github.io/shlink-web-client/${{ steps.generate_slug.outputs.slug }}"