Skip to content

Commit

Permalink
move variables to output
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Oct 17, 2023
1 parent 7f5633a commit 1872ad2
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@ jobs:
node-version: v16.19.1
- name: Install dependencies
run: |
pushd docs
pushd apps/docs
npm ci
- name: Set Version
id: set-version
run: |
echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_ENV}"
echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_OUTPUT}"
- name: Build
env:
PUBLIC_URL: "/${{ env._BRANCH_NAME_SHA }}/docs"
PUBLIC_URL: "/${{ steps.set-version.outputs._BRANCH_NAME_SHA }}/docs"
run: |
pushd docs
pushd apps/docs
npm run build
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docs-preview-build
path: docs/build
path: apps/docs/build
portal:
name: "Build Portal Bridge"
runs-on: "ubuntu-latest"
Expand Down Expand Up @@ -63,14 +64,15 @@ jobs:
git config user.name "xLabs CI"
git config user.email "[email protected]"
- name: Set Portal Bridge Version
id: set-version
run: |
cd portal
npm version $(node -p -e "require('./package.json').version")-P$(echo ${{ github.sha }} | cut -c -10)
echo "_PKG_VERSION=$(node -p -e "require('./package.json').version")" >> "${GITHUB_ENV}"
echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_ENV}"
echo "_PKG_VERSION=$(node -p -e "require('./package.json').version")" >> "${GITHUB_OUTPUT}"
echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_OUTPUT}"
- name: Build Portal Bridge
env:
PUBLIC_URL: "/${{ env._BRANCH_NAME_SHA }}"
PUBLIC_URL: "/${{ steps.set-version.outputs._BRANCH_NAME_SHA }}"
VITE_APP_VERSION: ${{ github.event.pull_request.head.ref }}
VITE_APP_CLUSTER: "mainnet"
run: |
Expand All @@ -97,8 +99,8 @@ jobs:
run: |
mkdir deploy-metadata
pushd deploy-metadata
echo ${_BRANCH_NAME_SHA} > .branch-sha
echo ${_PKG_VERSION} > .version
echo ${{ steps.set-version.outputs._BRANCH_NAME_SHA }} > .branch-sha
echo ${{ steps.set-version.outputs._PKG_VERSION }} > .version
- name: Upload Deploy metadata
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -162,19 +164,20 @@ jobs:
name: preview-deploy-metadata
path: deploy-metadata
- name: Set deploy metadata
id: set-version
run: |
echo "_PKG_VERSION=$(cat deploy-metadata/.version)" >> ${GITHUB_ENV}
echo "_BRANCH_NAME_SHA=$(cat deploy-metadata/.branch-sha)" >> ${GITHUB_ENV}
echo "_PKG_VERSION=$(cat deploy-metadata/.version)" >> ${GITHUB_OUTPUT}
echo "_BRANCH_NAME_SHA=$(cat deploy-metadata/.branch-sha)" >> ${GITHUB_OUTPUT}
- name: Trigger a preview Deploy
run: |
sleep 30s
mkdir -p preview/${{ env._BRANCH_NAME_SHA }}
pushd preview/${{ env._BRANCH_NAME_SHA }}
mkdir -p preview/${{ steps.set-version.outputs._BRANCH_NAME_SHA }}
pushd preview/${{ steps.set-version.outputs._BRANCH_NAME_SHA }}
[[ ! -f .latest ]] && touch .latest
[[ ! -f .artifacts ]] && touch .artifacts
cat .latest >> .artifacts
echo ${{ env._PKG_VERSION }} > .latest
echo ${{ steps.set-version.outputs._PKG_VERSION }} > .latest
git add .artifacts .latest
git commit -m"Update preview artifacts ${{ env._PKG_VERSION }}"
git commit -m"Update preview artifacts ${{ steps.set-version.outputs._PKG_VERSION }}"
git push
echo "The preview URL is: ${{ vars.PREVIEW_ROOT_URL }}/${{ env._BRANCH_NAME_SHA }}/" >> ${GITHUB_STEP_SUMMARY}
echo "The preview URL is: ${{ vars.PREVIEW_ROOT_URL }}/${{ steps.set-version.outputs._BRANCH_NAME_SHA }}/" >> ${GITHUB_STEP_SUMMARY}

0 comments on commit 1872ad2

Please sign in to comment.