|
| 1 | +# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. |
| 2 | +# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. |
| 3 | +# |
| 4 | + |
| 5 | +# Creates and Publishes the Oracle Resource Manager stack - v0.0.5 |
| 6 | + |
| 7 | +name: Generate stacks and publish release |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [ main ] |
| 12 | + paths: ['VERSION'] |
| 13 | + |
| 14 | +jobs: |
| 15 | + |
| 16 | + publish_stack: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Create stacks |
| 23 | + id: create_stacks |
| 24 | + run: | |
| 25 | + # |
| 26 | + STACKNAME=${{ github.event.repository.name }} |
| 27 | + STACK_FILES="*.tf schema.yaml README.md LICENSE VERSION .terraform.lock.hcl modules/" |
| 28 | + RELEASE=$(cat VERSION) |
| 29 | + ASSETS+="${STACKNAME}-stack.zip ${STACKNAME}-${RELEASE}.zip " |
| 30 | + echo "::group::Processing $STACKNAME" |
| 31 | + zip -r ${STACKNAME}-stack.zip $STACK_FILES -x "*.tfstat*" ".terraform/" || { printf '\n⛔ Unable to create %s stack.\n'; exit 1; } |
| 32 | + cp ${STACKNAME}-stack.zip ${STACKNAME}-${RELEASE}.zip || { printf '\n⛔ Unable to create %s stack.\n'; exit 1; } |
| 33 | + echo "::endgroup::" |
| 34 | + echo "::set-output name=assets::$ASSETS" |
| 35 | + echo "::set-output name=release::$RELEASE" |
| 36 | + echo "::set-output name=prefix::$STACKNAME" |
| 37 | +
|
| 38 | + - name: Prepare Release Notes |
| 39 | + run: | |
| 40 | + # |
| 41 | + printf '%s\n' '${{ steps.create_stacks.outputs.prefix }} Stack - v${{ steps.create_stacks.outputs.release }}' >release.md |
| 42 | + printf '%s\n' '' '## [![Deploy to Oracle Cloud][magic_button]][magic_stack]' >>release.md |
| 43 | + printf '%s\n' '' '' >>release.md |
| 44 | + printf '%s\n' '' '[magic_button]: https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg' >>release.md |
| 45 | + printf '%s\n' '' '[magic_stack]: https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/${{ github.repository }}/releases/download/${{ steps.create_stacks.outputs.release }}/${{ steps.create_stacks.outputs.prefix }}-${{ steps.create_stacks.outputs.release }}.zip' >>release.md |
| 46 | +
|
| 47 | + - name: Create Release |
| 48 | + run: gh release create ${{ steps.create_stacks.outputs.release }} --generate-notes -F release.md ${{ steps.create_stacks.outputs.assets }} |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments