build the provider in github #18
Workflow file for this run
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: build-downstreams | |
permissions: read-all | |
on: | |
push: | |
branches: | |
- main | |
- 'FEATURE-BRANCH-*' | |
pull_request: | |
jobs: | |
build-downstreams: | |
name: ${{ matrix.owner-repo }}-${{ matrix.branch }} | |
strategy: | |
fail-fast: false | |
matrix: | |
owner-repo: ['terraform-provider-google', 'terraform-provider-google-beta', 'terraform-google-conversion', 'docs-examples'] | |
runs-on: ubuntu-22.04 | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | |
with: | |
ruby-version: '3.1' | |
- name: Cache Bundler gems | |
uses: actions/cache@v2 | |
with: | |
path: mmv1/vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install Ruby dependencies | |
run: | | |
bundle config path mmv1/vendor/bundle | |
bundle install | |
working-directory: mmv1 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
# Cache Go modules | |
- name: Cache Go modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Build ${{ matrix.owner-repo }} | |
run: | | |
set -e | |
set -x | |
# Set GOPATH to a directory the runner user has access to | |
export GOPATH=~/go | |
function clone_repo() { | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
mkdir -p "$(dirname $OUTPUT_PATH)" | |
git clone $GITHUB_PATH $OUTPUT_PATH --branch $BASE_BRANCH | |
} | |
GH_REPO="${{ matrix.owner-repo }}" | |
if [ "$GH_REPO" == "docs-examples" ] && [ "$BASE_BRANCH" == "main" ]; then | |
BASE_BRANCH="master" | |
fi | |
OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
if [[ "$GH_REPO" == terraform-provider-google* ]]; then | |
UPSTREAM_OWNER=hashicorp | |
clone_repo | |
if [ "$GH_REPO" == "terraform-provider-google" ]; then | |
VERSION=ga | |
else | |
VERSION=beta | |
fi | |
make clean-provider | |
make provider | |
elif [ "$GH_REPO" == "terraform-google-conversion" ]; then | |
UPSTREAM_OWNER=GoogleCloudPlatform | |
clone_repo | |
make clean-tgc | |
make tgc | |
elif [ "$GH_REPO" == "docs-examples" ]; then | |
UPSTREAM_OWNER=terraform-google-modules | |
clone_repo | |
make tf-ocis | |
else | |
echo "case not supported" | |
exit 1 | |
fi | |
terraform-provider-google: | |
# name: ${{ matrix.repo }} | |
# strategy: | |
# matrix: | |
# repo: ['terraform-provider-google', 'terraform-provider-google-beta', 'terraform-google-conversion', 'docs-examples'] | |
# upstream-owner: ['hashicorp', 'hashicorp', 'GoogleCloudPlatform', 'terraform-google-modules'] | |
# branch: ['base-branch-name', 'new-branch-name'] # You will need to specify your base and new branch names here | |
runs-on: ubuntu-22.04 | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | |
with: | |
ruby-version: '3.1' | |
- name: Cache Bundler gems | |
uses: actions/cache@v2 | |
with: | |
path: mmv1/vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install Ruby dependencies | |
run: | | |
bundle config path mmv1/vendor/bundle | |
bundle install | |
working-directory: mmv1 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
# Cache Go modules | |
- name: Cache Go modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Build terraform-provider-google-beta | |
run: | | |
set -e | |
set -x | |
# Set GOPATH to a directory the runner user has access to | |
export GOPATH=~/go | |
function clone_repo() { | |
UPSTREAM_OWNER=hashicorp | |
GH_REPO=terraform-provider-google | |
LOCAL_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
mkdir -p "$(dirname $LOCAL_PATH)" | |
git clone $GITHUB_PATH $LOCAL_PATH --branch $BASE_BRANCH | |
} | |
if [ -z "$GITHUB_TOKEN" ]; then | |
echo "GITHUB_TOKEN environment variable is missing." | |
exit 1 | |
fi | |
clone_repo | |
git config --local user.name "Modular Magician" | |
git config --local user.email "[email protected]" | |
pushd mmv1 | |
pushd $LOCAL_PATH | |
go mod download | |
find . -type f -not -wholename "./.git*" -not -wholename "./.changelog*" -not -name ".travis.yml" -not -name ".golangci.yml" -not -name "CHANGELOG.md" -not -name "CHANGELOG_v*.md" -not -name "GNUmakefile" -not -name "docscheck.sh" -not -name "LICENSE" -not -name "README.md" -not -wholename "./examples*" -not -name ".go-version" -not -name ".hashibot.hcl" -print0 | xargs -0 git rm > /dev/null | |
popd | |
# Extracted build process from the script: | |
bundle exec compiler.rb -a -e terraform -o $LOCAL_PATH -v ga --no-docs | |
bundle exec compiler.rb -a -e terraform -o $LOCAL_PATH -v ga --no-code | |
pushd ../ | |
make tpgtools OUTPUT_PATH=$LOCAL_PATH VERSION=ga | |
make teamcity-servicemap-generate OUTPUT_PATH=$LOCAL_PATH VERSION=ga | |
popd | |
popd | |
terraform-provider-google-beta: | |
runs-on: ubuntu-22.04 | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | |
with: | |
ruby-version: '3.1' | |
- name: Cache Bundler gems | |
uses: actions/cache@v2 | |
with: | |
path: mmv1/vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install Ruby dependencies | |
run: | | |
bundle config path mmv1/vendor/bundle | |
bundle install | |
working-directory: mmv1 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
# Cache Go modules | |
- name: Cache Go modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Build terraform-provider-google-beta | |
run: | | |
set -e | |
set -x | |
# Set GOPATH to a directory the runner user has access to | |
export GOPATH=~/go | |
function clone_repo() { | |
UPSTREAM_OWNER=hashicorp | |
GH_REPO=terraform-provider-google-beta | |
LOCAL_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
mkdir -p "$(dirname $LOCAL_PATH)" | |
git clone $GITHUB_PATH $LOCAL_PATH --branch $BASE_BRANCH | |
} | |
if [ -z "$GITHUB_TOKEN" ]; then | |
echo "GITHUB_TOKEN environment variable is missing." | |
exit 1 | |
fi | |
clone_repo | |
git config --local user.name "Modular Magician" | |
git config --local user.email "[email protected]" | |
pushd mmv1 | |
pushd $LOCAL_PATH | |
go mod download | |
find . -type f -not -wholename "./.git*" -not -wholename "./.changelog*" -not -name ".travis.yml" -not -name ".golangci.yml" -not -name "CHANGELOG.md" -not -name "CHANGELOG_v*.md" -not -name "GNUmakefile" -not -name "docscheck.sh" -not -name "LICENSE" -not -name "README.md" -not -wholename "./examples*" -not -name ".go-version" -not -name ".hashibot.hcl" -print0 | xargs -0 git rm > /dev/null | |
popd | |
# Extracted build process from the script: | |
bundle exec compiler.rb -a -e terraform -o $LOCAL_PATH -v beta | |
pushd ../ | |
make tpgtools OUTPUT_PATH=$LOCAL_PATH VERSION=beta | |
make teamcity-servicemap-generate OUTPUT_PATH=$LOCAL_PATH VERSION=beta | |
popd | |
popd | |
terraform-google-conversion: | |
runs-on: ubuntu-22.04 | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | |
with: | |
ruby-version: '3.1' | |
- name: Cache Bundler gems | |
uses: actions/cache@v2 | |
with: | |
path: mmv1/vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install Ruby dependencies | |
run: | | |
bundle config path mmv1/vendor/bundle | |
bundle install | |
working-directory: mmv1 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
# Cache Go modules | |
- name: Cache Go modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Build terraform-google-conversion | |
run: | | |
set -e | |
set -x | |
# Set GOPATH to a directory the runner user has access to | |
export GOPATH=~/go | |
function clone_repo() { | |
UPSTREAM_OWNER=GoogleCloudPlatform | |
GH_REPO=terraform-google-conversion | |
LOCAL_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
mkdir -p "$(dirname $LOCAL_PATH)" | |
git clone $GITHUB_PATH $LOCAL_PATH --branch $BASE_BRANCH | |
} | |
if [ -z "$GITHUB_TOKEN" ]; then | |
echo "GITHUB_TOKEN environment variable is missing." | |
exit 1 | |
fi | |
clone_repo | |
git config --local user.name "Modular Magician" | |
git config --local user.email "[email protected]" | |
bundle exec compiler.rb -a -e terraform -f validator -o $LOCAL_PATH/tfplan2cai -v beta | |
popd | |
docs-examples: | |
runs-on: ubuntu-22.04 | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | |
with: | |
ruby-version: '3.1' | |
- name: Cache Bundler gems | |
uses: actions/cache@v2 | |
with: | |
path: mmv1/vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install Ruby dependencies | |
run: | | |
bundle config path mmv1/vendor/bundle | |
bundle install | |
working-directory: mmv1 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
# Cache Go modules | |
- name: Cache Go modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Build docs-examples | |
run: | | |
set -e | |
set -x | |
# Set GOPATH to a directory the runner user has access to | |
export GOPATH=~/go | |
if [ "$BASE_BRANCH" == "main" ]; then | |
BASE_BRANCH=master | |
fi | |
function clone_repo() { | |
UPSTREAM_OWNER=terraform-google-modules | |
GH_REPO=docs-examples | |
LOCAL_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | |
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO | |
mkdir -p "$(dirname $LOCAL_PATH)" | |
git clone $GITHUB_PATH $LOCAL_PATH --branch $BASE_BRANCH | |
} | |
if [ -z "$GITHUB_TOKEN" ]; then | |
echo "GITHUB_TOKEN environment variable is missing." | |
exit 1 | |
fi | |
clone_repo | |
git config --local user.name "Modular Magician" | |
git config --local user.email "[email protected]" | |
popd | |
echo "Build completed!" |