Skip to content

Commit 7e7af83

Browse files
Added - GitHub Actions workflow for creation of magic buttons
1 parent 56a51d9 commit 7e7af83

File tree

7 files changed

+127
-0
lines changed

7 files changed

+127
-0
lines changed

.github/workflows/examples.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Generate magic buttons for examples and publish
2+
3+
on:
4+
push:
5+
branches: [ release_gh ]
6+
paths: ['examples/**/**']
7+
8+
jobs:
9+
10+
publish_examples_magic_buttons:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Create description files
17+
run: |
18+
FOLDERS=$(ls -d examples/*/ | jq -R)
19+
for EXAMPLE_FOLDER in $FOLDERS;
20+
do
21+
RESOURCE=$(cut -d "/" -f 2 <<< "$EXAMPLE_FOLDER")
22+
FILENAME=description.md
23+
if [[ "$RESOURCE" != "zips" ]]; then
24+
if [ -f "./examples/$RESOURCE/$FILENAME" ]; then
25+
echo "./examples/$RESOURCE/$FILENAME exists."
26+
else
27+
touch ./examples/${RESOURCE}/${FILENAME}
28+
echo "./examples/$RESOURCE/$FILENAME created."
29+
fi
30+
fi
31+
done
32+
33+
- name: Commit and Push Changes
34+
run: |
35+
if [ -n "$(git status --porcelain)" ]; then
36+
git config --global user.name "tf-oci-pub"
37+
git config --global user.email "[email protected]"
38+
git pull origin release_gh
39+
git add ./examples/*
40+
git commit -m "Added - Description files for service examples"
41+
git push
42+
else
43+
echo "No changes!";
44+
fi
45+
46+
- name: Create README files
47+
run: |
48+
printf '## Terraform Oracle Cloud Infrastructure Provider Examples \n### Examples In This Directory \nThis directory contains Terraform configuration files showing how to create specific resources. The examples are intended to be as simple as possible, in most cases containing only the specific resource and any dependencies required for it to run. These do not represent production configurations or real world scenarios. The magic buttons of the examples can be found below.\n' > ./examples/${RESOURCE}/README.md
49+
FOLDERS=$(ls -d examples/*/ | jq -R)
50+
MAGIC_LINK="https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest/download/"
51+
for EXAMPLE_FOLDER in $FOLDERS;
52+
do
53+
RESOURCE=$(cut -d "/" -f 2 <<< "$EXAMPLE_FOLDER")
54+
if [[ "$RESOURCE" != "zips" ]]; then
55+
FILENAME=description.md
56+
FILEZIP=example_${RESOURCE}.zip
57+
cat ./examples/${RESOURCE}/$FILENAME > ./examples/${RESOURCE}/README.md
58+
printf '\n## Magic Button \n[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)]('${MAGIC_LINK}${FILEZIP}')' >>./examples/${RESOURCE}/README.md
59+
printf '%s\n' '- '${RESOURCE}'
60+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)]('${MAGIC_LINK}${FILEZIP}')' >> ./examples/README.md
61+
fi
62+
done
63+
64+
- name: Commit and Push Changes
65+
run: |
66+
if [ -n "$(git status --porcelain)" ]; then
67+
git config --global user.name "tf-oci-pub"
68+
git config --global user.email "[email protected]"
69+
git pull origin release_gh
70+
git add ./examples/*
71+
git commit -m "Added - README.md of service examples with magic button"
72+
git push
73+
else
74+
echo "No changes!";
75+
fi

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ vendor/github.com/oracle/oci-go-sdk/target
2727
.gitmodules
2828
internal/record
2929
.terraform.lock.hcl
30+
dist/
31+
examples/zips/*

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ release:
5959
extra_files:
6060
- glob: 'terraform-registry-manifest.json'
6161
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
62+
- glob: ./examples/zips/*
6263
# If you want to manually examine the release before its live, uncomment this line:
6364
# draft: true
6465
changelog:

examples/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Oracle Cloud Infrastructure Provider Examples
2+
3+
### Examples In This Directory
4+
This directory contains Terraform configuration files showing how to create specific resources. The examples are intended
5+
to be as simple as possible, in most cases containing only the specific resource and any dependencies required for it to run.
6+
These do not represent production configurations or real world scenarios.

examples/identity/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ___ ____ _ ____ _ _____
2+
# / _ \| _ \ / \ / ___| | | ____|
3+
# | | | | |_) | / _ \| | | | | _|
4+
# | |_| | _ < / ___ | |___| |___| |___
5+
# \___/|_| \_/_/ \_\____|_____|_____|
6+
***
7+
8+
## Identity Resource and Datasource Examples
9+
10+
This example demonstrates the following Identity concepts:
11+
* Show tenancy details and list OCI regions and region subscriptions
12+
* List and filter Availability Domains
13+
* Create and list compartments
14+
* Create users, add an api key and access their password
15+
* Create groups and add users
16+
* Create policies affecting groups and compartments
17+
* Create dynamic groups and policies that govern it

examples/object_storage/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ___ ____ _ ____ _ _____
2+
# / _ \| _ \ / \ / ___| | | ____|
3+
# | | | | |_) | / _ \| | | | | _|
4+
# | |_| | _ < / ___ | |___| |___| |___
5+
# \___/|_| \_/_/ \_\____|_____|_____|
6+
***
7+
8+
## Object Storage Resource and Datasource Examples
9+
10+
This example demonstrates the following Object Storage concepts:
11+
* Creating Objects and buckets
12+
* Defining Preauthenticated Requests for objects and buckets
13+
* Accessing and modifying object store namespace metatdata

scripts/create-zips.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
rm -r examples/zips
3+
mkdir -p examples/zips
4+
for EXAMPLE_FOLDER in examples/*/;
5+
do
6+
RESOURCE=$(cut -d "/" -f 2 <<< "$EXAMPLE_FOLDER")
7+
if [[ "$RESOURCE" != "zips" ]]; then
8+
FILEZIP=example_${RESOURCE}.zip
9+
FOLDER=$(echo "$EXAMPLE_FOLDER" | tr -d '"')
10+
zip -r $FILEZIP $FOLDER || { printf '\n Unable to create zips.\n'; exit 1; }
11+
mv $FILEZIP ./examples/zips
12+
fi
13+
done

0 commit comments

Comments
 (0)