Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reusable workflow for publishing docs #85

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/provider-updoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Updoc

on:
workflow_call:
secrets:
UPBOUND_CI_PROD_BUCKET_SA:
required: true

env:
GO_VERSION: '1.19'
UPTEST_VERSION: '83bd901'

jobs:
publish-docs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-updoc-artifacts-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-updoc-artifacts-

- name: Cache Go Dependencies
uses: actions/cache@v3
with:
path: .work/pkg
key: ${{ runner.os }}-updoc-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-updoc-pkg-

- name: Create Service Account File
env:
GAC: ${{ secrets.UPBOUND_CI_PROD_BUCKET_SA }}
run: |
echo "${GAC}" > sa.json

- name: Upload Docs
env:
GOOGLE_APPLICATION_CREDENTIALS: sa.json
PROVIDER_NAME: ${GITHUB_REPOSITORY#*/}
VER_MAJOR_MINOR: v${GITHUB_REF#"refs/heads/release-"}
run: |
if [[ "${GITHUB_REF##*/}" == release-* ]]; then
echo "Publishing Docs for ${{ env.PROVIDER_NAME }}, ${{ env.VER_MAJOR_MINOR }}"
go run github.com/upbound/uptest/cmd/updoc@${{ env.UPTEST_VERSION }} upload --docs-dir=./docs --name=${{ env.PROVIDER_NAME }} --version=${{ env.VER_MAJOR_MINOR }} --bucket-name=bucket-marketplace-docs-production --cdn-domain=https://user-content.upbound.io
else
echo "This job can only be run on release branches"
exit 1
fi