Skip to content

build the provider in github #6

build the provider in github

build the provider in github #6

name: magic-modules
permissions: read-all
on:
pull_request:
jobs:
terraform-provider-google:
runs-on: ubuntu-22.04
env:
BASE_BRANCH: main
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@v4
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/hashicorp/terraform-provider-google-beta
GITHUB_PATH=https://modular-magician:[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
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