-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from konpyutaika/AMIOS-11/feat/iup/terraform-mo…
…dules/github-workflow-release [AMIOS-11] feat(iup/terraform modules): Github workflow release
- Loading branch information
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "Data Product Experience Plane release" | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
terraform-modules-oci-release: | ||
uses: ./.github/workflows/terraform-modules-oci-release.yml | ||
with: | ||
organization_layer_name: platform | ||
team_name: data-product-experience-plane | ||
products_path: "products" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "Infrastructure Utility Plane release" | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
terraform-modules-oci-release: | ||
uses: ./.github/workflows/terraform-modules-oci-release.yml | ||
with: | ||
organization_layer_name: platform | ||
team_name: infrastructure-utility-plane | ||
products_path: "products" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "Mesh experience plane release" | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
terraform-modules-oci-release: | ||
uses: ./.github/workflows/terraform-modules-oci-release.yml | ||
with: | ||
organization_layer_name: platform | ||
team_name: mesh-experience-plane | ||
products_path: "products" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: " Terraform modules release on OCI" | ||
|
||
permissions: | ||
contents: write # needed to write releases | ||
id-token: write # needed for keyless signing | ||
packages: write # needed for ghcr access | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
runs-on: | ||
required: false | ||
type: string | ||
default: ubuntu-latest | ||
organization_layer_name: | ||
required: false | ||
type: string | ||
default: platform | ||
team_name: | ||
required: true | ||
type: string | ||
products_path: | ||
required: false | ||
type: string | ||
default: "products" | ||
|
||
|
||
env: | ||
REPOSITORY: "${{ github.event.repository.name }}" | ||
|
||
jobs: | ||
build-push: | ||
runs-on: "${{ inputs.runs-on }}" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: sigstore/cosign-installer@main | ||
- uses: fluxcd/flux2/action@main | ||
- name: Prepare tag | ||
id: prepare_tag | ||
run: | | ||
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}" | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF/refs\/tags\//} | ||
fi | ||
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
echo ::set-output name=VERSION::${VERSION} | ||
- name: Docker login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish OCI | ||
run: | | ||
echo "${{ steps.prepare_tag.outputs.VERSION }}" | ||
basePath="${{ inputs.organization_layer_name }}/${{ inputs.team_name }}/${{ inputs.products_path }}" | ||
for terraformPath in $(find "$basePath" -type d -name 'terraform' -exec dirname {} \; | sed "s|^$basePath/||" | sort | uniq); do | ||
productName=${{ inputs.organization_layer_name }}-${{ inputs.team_name }}-$(echo "$terraformPath" | sed 's/\//-/g') | ||
echo "Publishing $productName" | ||
bash -x ./platform/infrastructure-utility-plane/products/infraform/publish-oci.sh ${{ steps.prepare_tag.outputs.VERSION }} "${basePath}/${terraformPath}/terraform" "${productName}" | ||
done |
24 changes: 24 additions & 0 deletions
24
platform/infrastructure-utility-plane/products/infraform/publish-oci.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pushd . | ||
|
||
|
||
REPOSITORY=konpyutaika/data-mesh/terraform-modules | ||
SOURCE="$(git config --get remote.origin.url)" | ||
REVISION="$(git branch --show-current)/$(git rev-parse HEAD)" | ||
|
||
flux push artifact \ | ||
oci://ghcr.io/${REPOSITORY}/$3:$TAG \ | ||
--path="$2" \ | ||
--source=$SOURCE \ | ||
--revision=$REVISION | ||
|
||
flux tag artifact \ | ||
oci://ghcr.io/${REPOSITORY}/$3:$TAG \ | ||
--tag latest | ||
|
||
flux tag artifact \ | ||
oci://ghcr.io/${REPOSITORY}/$3:$TAG \ | ||
--tag $1 | ||
|
||
rm -rf $tmp_dir | ||
|
||
popd |