diff --git a/.github/workflows/dpep-release.yml b/.github/workflows/dpep-release.yml new file mode 100644 index 0000000..8d9ed61 --- /dev/null +++ b/.github/workflows/dpep-release.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/iup-release.yml b/.github/workflows/iup-release.yml new file mode 100644 index 0000000..cf02db5 --- /dev/null +++ b/.github/workflows/iup-release.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/mep-release.yml b/.github/workflows/mep-release.yml new file mode 100644 index 0000000..ec1e6a2 --- /dev/null +++ b/.github/workflows/mep-release.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/terraform-modules-oci-release.yml b/.github/workflows/terraform-modules-oci-release.yml new file mode 100644 index 0000000..77c9d19 --- /dev/null +++ b/.github/workflows/terraform-modules-oci-release.yml @@ -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 diff --git a/platform/infrastructure-utility-plane/products/infraform/publish-oci.sh b/platform/infrastructure-utility-plane/products/infraform/publish-oci.sh new file mode 100755 index 0000000..8365983 --- /dev/null +++ b/platform/infrastructure-utility-plane/products/infraform/publish-oci.sh @@ -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 \ No newline at end of file