Skip to content

Commit

Permalink
Merge pull request #2 from konpyutaika/AMIOS-11/feat/iup/terraform-mo…
Browse files Browse the repository at this point in the history
…dules/github-workflow-release

[AMIOS-11] feat(iup/terraform modules): Github workflow release
  • Loading branch information
erdrix authored Mar 8, 2024
2 parents f1bd235 + 753bca8 commit 964c408
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/dpep-release.yml
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"
14 changes: 14 additions & 0 deletions .github/workflows/iup-release.yml
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"
14 changes: 14 additions & 0 deletions .github/workflows/mep-release.yml
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"
61 changes: 61 additions & 0 deletions .github/workflows/terraform-modules-oci-release.yml
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
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

0 comments on commit 964c408

Please sign in to comment.