Add CORSO_VERSION to docs env when building (#1215)

## Description

Adds the new CORSO_VERSION env needed to build docs in CI.

![2022-10-19-16-02-13](https://user-images.githubusercontent.com/14259816/196668301-cb5ad90c-4735-4132-b3ea-764d30948a62.png)

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [x] 🗺️ Documentation
- [ ] 🤖 Test
- [x] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* fixes https://github.com/alcionai/corso/issues/29
* https://github.com/alcionai/corso/pull/1205

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2022-10-21 02:18:30 +05:30 committed by GitHub
parent f0e28ea4c7
commit 7221d616ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 14 deletions

View File

@ -200,10 +200,13 @@ jobs:
environment: Testing
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-env.outputs.environment }}
environment: ${{ steps.environment.outputs.environment }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Figure out environment
id: set-env
id: environment
run: |
if ${{ startsWith(github.ref, 'refs/tags/') }}; then
echo "set-output name=environment::Production"
@ -213,6 +216,18 @@ jobs:
echo "::set-output name=environment::Testing"
fi
- name: Get version string
id: version
run: |
if ${{ startsWith(github.ref, 'refs/tags/') }}; then
echo "set-output name=version::$(git describe --exact-match --tags $(git rev-parse HEAD))"
echo "::set-output name=version::$(git describe --exact-match --tags $(git rev-parse HEAD))"
else
echo "set-output name=version::$(echo unreleased-$(git rev-parse --short HEAD))"
echo "::set-output name=version::$(echo unreleased-$(git rev-parse --short HEAD))"
fi
Publish-Binary:
needs: [Test-Suite, Linting, Docs-Linting, SetEnv]
@ -233,9 +248,6 @@ jobs:
with:
go-version-file: src/go.mod
- id: version
run: echo "::set-output name=version::$(git describe --exact-match --tags $(git rev-parse HEAD) 2>/dev/null || echo unreleased)-$(git rev-parse --short HEAD)"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
@ -246,7 +258,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUDDERSTACK_CORSO_WRITE_KEY: ${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}
RUDDERSTACK_CORSO_DATA_PLANE_URL: ${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}
CORSO_VERSION: ${{ steps.version.outputs.version }}
CORSO_VERSION: ${{ needs.SetEnv.outputs.version }}
- name: Upload assets
uses: actions/upload-artifact@v3
@ -272,11 +284,6 @@ jobs:
name: cli-docs
path: docs/docs/cli
- name: Build docs
run: |
npm ci
CORSO_DOCS_BASEURL="/preview/" npm run build # TODO: update base url once finalized
- name: Configure AWS credentials from Test account
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
uses: aws-actions/configure-aws-credentials@v1
@ -285,6 +292,13 @@ jobs:
role-session-name: integration-testing
aws-region: us-east-1
- name: Build docs
env:
CORSO_VERSION: ${{ needs.SetEnv.outputs.version }}
run: |
npm ci
CORSO_DOCS_BASEURL="/preview/" npm run build # TODO: update base url once finalized
- name: Push docs
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
run: |
@ -347,4 +361,4 @@ jobs:
CORSO_BUILD_LDFLAGS=-X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey=${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}' -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL=${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}' -X 'github.com/alcionai/corso/src/cli.version=$(git describe --exact-match --tags $(git rev-parse HEAD) 2>/dev/null || echo unreleased)-$(git rev-parse --short HEAD)'
# use the github cache
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

View File

@ -6,8 +6,8 @@ CORSO_BUILD_MOD := ${CORSO_BUILD_DIR}/mod
CORSO_BUILD_BIN := ${CORSO_BUILD_DIR}/bin
CORSO_REPO := /go/src/github.com/alcionai/corso
CORSO_LOCAL_PATH := $(shell git rev-parse --show-toplevel)
CORSO_VERSION := $(shell git rev-parse --short HEAD)
DOCSC := docker run --rm -it -p 3000:3000 -v ${PWD}:/usr/src/docs --env CORSO_VERSION=${CORSO_VERSION} corso/docs
GIT_SHA := $(shell git rev-parse --short HEAD)
DOCSC := docker run --rm -it -p 3000:3000 -v ${PWD}:/usr/src/docs --env CORSO_VERSION=unreleased-${GIT_SHA} corso/docs
CBASE := docker run --rm -it \
-v ${CORSO_LOCAL_PATH}:${CORSO_REPO} -v ${CORSO_BUILD_DIR}:${CORSO_BUILD_DIR} \
--env GOCACHE=${CORSO_BUILD_CACHE} --env GOMODCACHE=${CORSO_BUILD_MOD} --env GOTMPDIR=${CORSO_BUILD_DIR} \