├── .github └── workflows │ └── test-action-script.yml ├── .gitignore ├── LICENSE ├── README.adoc ├── action.yml └── setup-oracledb.sh /.github/workflows/test-action-script.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Since: October 2024 3 | # Author: gvenzl 4 | # Name: test-action-script.yml 5 | # Description: GitHub Actions Oracle load tests 6 | # 7 | # Copyright 2024 Gerald Venzl 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | name: Test action script 'setup-oracledb.sh' 23 | on: [push, pull_request] 24 | 25 | jobs: 26 | 27 | run-with-default-parameters: 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | 32 | - uses: actions/checkout@v4 33 | 34 | - name: Invoke script 35 | run : | 36 | export SETUP_HEALTH_MAX_RETRIES=10 37 | export SETUP_APP_USER="TEST" 38 | export SETUP_APP_USER_PASSWORD="LetsTest1" 39 | ./setup-oracledb.sh 40 | 41 | trigger-failure-with-invalid-app-user-password: 42 | runs-on: ubuntu-latest 43 | 44 | steps: 45 | 46 | - uses: actions/checkout@v4 47 | 48 | - name: Invoke script 49 | run : | 50 | export SETUP_HEALTH_MAX_RETRIES=10 51 | export SETUP_APP_USER="SYS" 52 | export SETUP_APP_USER_PASSWORD="foo" 53 | # Negative test: setup is expected to fail 54 | # If it fails, return 0 (success), if it succeeds, return 1 (failure) 55 | ./setup-oracledb.sh && exit 1 || exit 0 56 | 57 | test-with-container-network: 58 | runs-on: ubuntu-latest 59 | steps: 60 | - uses: actions/checkout@v4 61 | - name: Invoke script 62 | run: | 63 | podman network create test-network 64 | export SETUP_CONTAINER_NETWORK="test-network" 65 | export SETUP_HEALTH_MAX_RETRIES=10 66 | export SETUP_APP_USER="TEST" 67 | export SETUP_APP_USER_PASSWORD="LetsTest1" 68 | ./setup-oracledb.sh 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Setup Oracle Database 2 | :linkattrs: 3 | :project-owner: gvenzl 4 | :project-name: setup-oracle-free 5 | :project-tag: v1 6 | 7 | ifdef::env-github[] 8 | :tip-caption: :bulb: 9 | :note-caption: :information_source: 10 | :important-caption: :heavy_exclamation_mark: 11 | :caution-caption: :fire: 12 | :warning-caption: :warning: 13 | endif::[] 14 | 15 | image:https://img.shields.io/github/v/release/{project-owner}/{project-name}["GitHub release", link="https://github.com/gvenzl/setup-oracle-free/releases"] 16 | 17 | Sets up Oracle Database using container images from link:https://github.com/gvenzl/oci-oracle-free[gvenzl/oci-oracle-free]. 18 | 19 | IMPORTANT: Only *Linux* runners are supported for the time being. 20 | 21 | == Inputs 22 | 23 | Following inputs may be used as `step.with` keys: 24 | 25 | [%header,cols="<2,<,<,<3",width="100%"] 26 | |=== 27 | | Name | Required | Default | Description 28 | | tag | | latest | Valid image tag from link:https://github.com/gvenzl/oci-oracle-free[gvenzl/oci-oracle-free] 29 | | port | | 1521 | Exposed port for database connections 30 | | volume | | | Volume to be mounted to contain database files 31 | | oracle-password | | | Password for the Oracle Database `SYS` and `SYSTEM` users 32 | | oracle-database | | | Create a new pluggable database with the specified name 33 | | app-user | true | | Create a new database schema user with the specified name 34 | | app-user-password | true | | Define a password for the database schema user specified by `app-user` 35 | | setup-scripts | | | Path to folder with additional database setup scripts 36 | | startup-scripts | | | Path to folder with additional database startup scripts 37 | | container-name | | oracledb | Name for the database container 38 | | container-network | | | Connects the container to an already established network. 39 | | health-max-retries | | 60 | Number of tries for checking that the database is up 40 | | health-interval | | 3 | Time interval between health checks, in seconds 41 | | container-runtime | | podman | The container runtime to use (`podman` or `docker`) 42 | |=== 43 | 44 | A random password will be generated automatically if a value for `oracle-password` is not supplied. 45 | 46 | == Usage 47 | 48 | === Basic usage 49 | 50 | All defaults enabled as explained link:https://github.com/gvenzl/oci-oracle-free#github-actions[here]. 51 | 52 | [source,yaml] 53 | [subs="attributes"] 54 | ---- 55 | jobs: 56 | test: 57 | runs-on: ubuntu-latest 58 | steps: 59 | - uses: actions/checkout@v4 60 | - uses: {project-owner}/{project-name}@{project-tag} 61 | with: 62 | app-user: <username> 63 | app-user-password: <password> 64 | ---- 65 | 66 | NOTE: You must define values of `app-user` and `app-user-password`, either explicitly, via env vars, or secrets. 67 | 68 | === Custom Database Password 69 | 70 | Set a custom database password that you may use at a later step to perform admin operations. 71 | 72 | [source,yaml] 73 | [subs="attributes"] 74 | ---- 75 | jobs: 76 | test: 77 | runs-on: ubuntu-latest 78 | steps: 79 | - uses: actions/checkout@v4 80 | - uses: {project-owner}/{project-name}@{project-tag} 81 | with: 82 | app-user: <username> 83 | app-user-password: <password> 84 | oracle-password: ${{ secrets.ORACLE_PASSWORD }} 85 | ---- 86 | 87 | NOTE: Use a secret or explicitly mask the password before using it. 88 | 89 | === Persistent Database Container 90 | 91 | Database files placed at `~/database-files` inside the GitHub Action runner will be read and used. You may choose a different location according to your needs. 92 | 93 | [source,yaml] 94 | [subs="attributes"] 95 | ---- 96 | jobs: 97 | test: 98 | runs-on: ubuntu-latest 99 | steps: 100 | - uses: actions/checkout@v4 101 | - run: mkdir ${{ github.workspace }}/database-files 102 | - uses: {project-owner}/{project-name}@{project-tag} 103 | with: 104 | app-user: <username> 105 | app-user-password: <password> 106 | volume: ${{ github.workspace }}/database-files 107 | ---- 108 | 109 | NOTE: The directory `~/database-files` must be writtable by the `oracle` (uid: 54321) user. 110 | 111 | === Init scripts 112 | 113 | SQL scripts placed at `~/my-scripts` inside the GitHub Action runner will be used to post initialize the database. 114 | 115 | [source,yaml] 116 | [subs="attributes"] 117 | ---- 118 | jobs: 119 | test: 120 | runs-on: ubuntu-latest 121 | steps: 122 | - uses: actions/checkout@v4 123 | - uses: {project-owner}/{project-name}@{project-tag} 124 | with: 125 | app-user: <username> 126 | app-user-password: <password> 127 | startup-scripts: ${{ github.workspace }}/my-scripts 128 | ---- 129 | 130 | == Why 131 | 132 | The documentation from link:https://github.com/gvenzl/oci-oracle-free[gvenzl/oci-oracle-free] shows that GitHub services may 133 | be used with the images. An example is shown next: 134 | 135 | [source, yaml] 136 | ---- 137 | services: 138 | # Oracle service (label used to access the service container) 139 | oracle: 140 | # Docker Hub image (feel free to change the tag "latest" to any other available one) 141 | image: gvenzl/oracle-free:latest 142 | 143 | # Provide passwords and other environment variables to container 144 | env: 145 | ORACLE_RANDOM_PASSWORD: true 146 | APP_USER: my_user 147 | APP_USER_PASSWORD: my_password_which_I_really_should_change 148 | 149 | # Forward Oracle port 150 | ports: 151 | - 1521:1521 152 | 153 | # Provide healthcheck script options for startup 154 | options: >- 155 | --health-cmd healthcheck.sh 156 | --health-interval 10s 157 | --health-timeout 5s 158 | --health-retries 10 159 | ---- 160 | 161 | This action builds on top of the capabilities offered by `gvenzl/oci-oracle-free` adding the following options: 162 | 163 | - managed docker image name & tag 164 | - managed database port 165 | - automatic mapping of database volume path (mapped to `/opt/oracle/oradata`) 166 | - automatic mapping of external database initialization scripts 167 | - automatic health checks upon starting the container 168 | 169 | Thus, switching from container service to action results in the following configuration: 170 | 171 | [source,yaml] 172 | [subs="attributes"] 173 | ---- 174 | jobs: 175 | test: 176 | runs-on: ubuntu-latest 177 | steps: 178 | - uses: actions/checkout@v4 179 | - uses: {project-owner}/{project-name}@{project-tag} 180 | with: 181 | app-user: my_user 182 | app-user-password: my_password_which_I_really_should_change 183 | ---- 184 | 185 | Updating this configuration to persist the database volume between runs: 186 | 187 | [source,yaml] 188 | [subs="attributes"] 189 | ---- 190 | jobs: 191 | test: 192 | runs-on: ubuntu-latest 193 | steps: 194 | - uses: actions/checkout@v4 195 | - run: mkdir ${{ github.workspace }}/database-files 196 | - uses: {project-owner}/{project-name}@{project-tag} 197 | with: 198 | app-user: my_user 199 | app-user-password: my_password_which_I_really_should_change 200 | volume: ${{ github.workspace }}/database-files 201 | ---- 202 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Setup-Oracle-DB-Free 2 | 3 | description: 'Setup Oracle Database Free on Docker or Podman.' 4 | 5 | branding: 6 | icon: 'database' 7 | color: 'red' 8 | 9 | inputs: 10 | tag: 11 | description: 'Valid image tag from https://github.com/gvenzl/oci-oracle-free' 12 | default: '' 13 | required: false 14 | 15 | port: 16 | description: 'Exposed port for database connections.' 17 | default: '1521' 18 | required: false 19 | 20 | container-runtime: 21 | description: 'Container runtime to use (docker or podman).' 22 | default: 'podman' 23 | required: false 24 | 25 | container-name: 26 | description: 'Name for the container' 27 | default: 'oracledb' 28 | required: false 29 | 30 | health-max-retries: 31 | description: 'Number of tries for checking database is up' 32 | default: '60' 33 | required: false 34 | 35 | health-interval: 36 | description: 'Time interval between health checks, in seconds' 37 | default: '3' 38 | required: false 39 | 40 | volume: 41 | description: 'Volume containing database files.' 42 | required: false 43 | 44 | oracle-password: 45 | description: 'Password for the Oracle Database `SYS` and `SYSTEM` users.' 46 | required: false 47 | 48 | oracle-database: 49 | description: 'Create a new pluggable database with the specified name.' 50 | required: false 51 | 52 | app-user: 53 | description: 'Create a new database schema user with the specified name.' 54 | required: true 55 | 56 | app-user-password: 57 | description: 'Define a password for the database schema user specified by `app-user`.' 58 | required: true 59 | 60 | setup-scripts: 61 | description: 'Additional database setup scripts.' 62 | required: false 63 | 64 | startup-scripts: 65 | description: 'Additional database initialization scripts.' 66 | required: false 67 | 68 | container-network: 69 | description: 'Connects the container to an already established network.' 70 | required: false 71 | 72 | runs: 73 | using: 'composite' 74 | steps: 75 | - name: Check runner 76 | if: runner.os != 'Linux' 77 | shell: bash 78 | run: | 79 | echo "::error:: Only Linux runners are supported at the moment." 80 | exit 1 81 | 82 | - name: Setup database 83 | shell: bash 84 | if: inputs.image == '' 85 | run: "${{ github.action_path }}/setup-oracledb.sh" 86 | env: 87 | SETUP_TAG: ${{ inputs.tag }} 88 | SETUP_PORT: ${{ inputs.port }} 89 | SETUP_CONTAINER_RUNTIME: ${{ inputs.container-runtime }} 90 | SETUP_CONTAINER_NAME: ${{ inputs.container-name }} 91 | SETUP_HEALTH_MAX_RETRIES: ${{ inputs.health-max-retries }} 92 | SETUP_HEALTH_INTERVAL: ${{ inputs.health-interval }} 93 | SETUP_VOLUME: ${{ inputs.volume }} 94 | SETUP_ORACLE_PASSWORD: ${{ inputs.oracle-password }} 95 | SETUP_ORACLE_DATABASE: ${{ inputs.oracle-database }} 96 | SETUP_APP_USER: ${{ inputs.app-user }} 97 | SETUP_APP_USER_PASSWORD: ${{ inputs.app-user-password }} 98 | SETUP_SETUP_SCRIPTS: ${{ inputs.setup-scripts }} 99 | SETUP_STARTUP_SCRIPTS: ${{ inputs.startup-scripts }} 100 | SETUP_CONTAINER_NETWORK: ${{ inputs.container-network }} 101 | -------------------------------------------------------------------------------- /setup-oracledb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Since: January, 2023 3 | # Author: aalmiray, gvenzl 4 | # 5 | # Copyright 2023-2024 Andres Almiray, Gerald Venzl 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | ORADATA="/opt/oracle/oradata" 20 | DEFAULT_CONTAINER_NAME="oracledb" 21 | 22 | HEALTH_MAX_RETRIES=0 23 | HEALTH_INTERVAL=0 24 | 25 | CONTAINER_RUNTIME="" 26 | CONTAINER_ARGS="" 27 | CONTAINER_IMAGE="" 28 | CONTAINER_NAME="" 29 | VALIDATION="OK" 30 | FASTSTART="" 31 | 32 | ############################################################################### 33 | echo "::group::🔍 Verifying inputs" 34 | 35 | # CONTAINER_RUNTIME 36 | # If the setup container runtime is set, verify the runtime is available 37 | if [ -n "${SETUP_CONTAINER_RUNTIME}" ]; then 38 | # Container runtime exists 39 | if type "${SETUP_CONTAINER_RUNTIME}" > /dev/null; then 40 | CONTAINER_RUNTIME="${SETUP_CONTAINER_RUNTIME}" 41 | echo "✅ container runtime set to ${CONTAINER_RUNTIME}" 42 | fi 43 | fi 44 | # If container runtime is empty (either doesn't exist, or wasn't passed on), find default 45 | if [ -z "${CONTAINER_RUNTIME}" ]; then 46 | if type podman > /dev/null; then 47 | CONTAINER_RUNTIME="podman" 48 | echo "☑️️ container runtime set to ${CONTAINER_RUNTIME} (default)" 49 | elif type docker > /dev/null; then 50 | CONTAINER_RUNTIME="docker" 51 | echo "☑️️ container runtime set to ${CONTAINER_RUNTIME} (default)" 52 | else 53 | echo "❌ container runtime not available." 54 | VALIDATION="" 55 | fi 56 | fi 57 | 58 | # TAG 59 | if [ -z "${SETUP_TAG}" ]; then 60 | SETUP_TAG="latest" 61 | fi 62 | echo "✅ tag set to ${SETUP_TAG}" 63 | CONTAINER_IMAGE="gvenzl/oracle-free:${SETUP_TAG}" 64 | 65 | # PORT 66 | if [ -z "${SETUP_PORT}" ]; then 67 | echo "☑️️ container host port set to 1521 (default)" 68 | SETUP_PORT=1521 69 | fi 70 | echo "✅ port set to ${SETUP_PORT}" 71 | CONTAINER_ARGS="${CONTAINER_ARGS} -p 1521:${SETUP_PORT}" 72 | 73 | # CONTAINER_NAME 74 | if [ -n "${SETUP_CONTAINER_NAME}" ]; then 75 | echo "✅ container name set to ${SETUP_CONTAINER_NAME}" 76 | CONTAINER_NAME=${SETUP_CONTAINER_NAME} 77 | else 78 | echo "☑️️ container name set to ${DEFAULT_CONTAINER_NAME} (default)" 79 | CONTAINER_NAME=${DEFAULT_CONTAINER_NAME} 80 | fi 81 | CONTAINER_ARGS="${CONTAINER_ARGS} --name ${CONTAINER_NAME}" 82 | 83 | 84 | # Container network 85 | if [ -n "${SETUP_CONTAINER_NETWORK}" ]; then 86 | echo "✅ container network set to ${SETUP_CONTAINER_NETWORK}" 87 | CONTAINER_ARGS="${CONTAINER_ARGS} --network ${SETUP_CONTAINER_NETWORK}" 88 | fi 89 | 90 | # HEALTH_MAX_RETRIES 91 | if [ -n "${SETUP_HEALTH_MAX_RETRIES}" ]; then 92 | echo "✅ health max retries set to ${SETUP_HEALTH_MAX_RETRIES}" 93 | HEALTH_MAX_RETRIES=$SETUP_HEALTH_MAX_RETRIES 94 | else 95 | # Set default if scripts is invoked outside the GH Action (otherwise this is set in action.yml) 96 | echo "☑️️ health max retries set to 60 (default)" 97 | HEALTH_MAX_RETRIES=60 98 | fi 99 | 100 | # HEALTH_INTERVAL 101 | if [ -n "${SETUP_HEALTH_INTERVAL}" ]; then 102 | echo "✅ health interval set to ${SETUP_HEALTH_INTERVAL}" 103 | HEALTH_INTERVAL=${SETUP_HEALTH_INTERVAL} 104 | else 105 | # Set default if scripts is invoked outside the GH Action (otherwise this is set in action.yml) 106 | echo "☑️️ health interval set to 3 (default)" 107 | HEALTH_INTERVAL=3 108 | fi 109 | 110 | # VOLUME 111 | if [ -n "${SETUP_VOLUME}" ]; then 112 | # skip volume if tag ends with 'faststart' 113 | FASTSTART=$(echo "${SETUP_TAG}" | grep -Eq "^.*faststart$" && echo "true" || echo "false") 114 | if [ "${FASTSTART}" = "true" ]; then 115 | echo "⚠️ Volume ${SETUP_VOLUME} skipped because tag is ${SETUP_TAG}" 116 | else 117 | echo "✅ volume set to ${SETUP_VOLUME} mapped to ${ORADATA}" 118 | CONTAINER_ARGS="${CONTAINER_ARGS} -v ${SETUP_VOLUME}:${ORADATA}" 119 | chmod 777 "${SETUP_VOLUME}" 120 | fi 121 | fi 122 | 123 | # PASSWORD 124 | if [ -z "${SETUP_ORACLE_PASSWORD}" ]; then 125 | echo "⚠️ Oracle password will be randomly generated" 126 | CONTAINER_ARGS="${CONTAINER_ARGS} -e ORACLE_RANDOM_PASSWORD=true" 127 | else 128 | echo "✅ ORACLE_PASSWORD explicitly set" 129 | CONTAINER_ARGS="${CONTAINER_ARGS} -e ORACLE_PASSWORD=${SETUP_ORACLE_PASSWORD}" 130 | fi 131 | 132 | # DATABASE 133 | if [ -n "${SETUP_ORACLE_DATABASE}" ]; then 134 | echo "✅ database name set to ${SETUP_ORACLE_DATABASE}" 135 | CONTAINER_ARGS="${CONTAINER_ARGS} -e ORACLE_DATABASE=${SETUP_ORACLE_DATABASE}" 136 | fi 137 | 138 | # APP_USER 139 | if [ -n "${SETUP_APP_USER}" ]; then 140 | echo "✅ APP_USER explicitly set" 141 | CONTAINER_ARGS="${CONTAINER_ARGS} -e APP_USER=${SETUP_APP_USER}" 142 | else 143 | echo "❌ APP_USER is not set" 144 | VALIDATION="" 145 | fi 146 | 147 | # APP_USER_PASSWORD 148 | if [ -n "${SETUP_APP_USER_PASSWORD}" ]; then 149 | echo "✅ APP_USER_PASSWORD explicitly set" 150 | CONTAINER_ARGS="${CONTAINER_ARGS} -e APP_USER_PASSWORD=${SETUP_APP_USER_PASSWORD}" 151 | else 152 | echo "❌ APP_USER_PASSWORD is not set" 153 | VALIDATION="" 154 | fi 155 | 156 | # SETUP_SCRIPTS 157 | if [ -n "${SETUP_SETUP_SCRIPTS}" ]; then 158 | echo "✅ setup scripts from ${SETUP_SETUP_SCRIPTS}" 159 | CONTAINER_ARGS="${CONTAINER_ARGS} -v ${SETUP_SETUP_SCRIPTS}:/container-entrypoint-initdb.d" 160 | fi 161 | 162 | # STARTUP_SCRIPTS 163 | if [ -n "${SETUP_STARTUP_SCRIPTS}" ]; then 164 | echo "✅ startup scripts from ${SETUP_STARTUP_SCRIPTS}" 165 | CONTAINER_ARGS="${CONTAINER_ARGS} -v ${SETUP_STARTUP_SCRIPTS}:/container-entrypoint-startdb.d" 166 | fi 167 | 168 | if [ -n "${VALIDATION}" ]; then 169 | echo "✅ All inputs are valid" 170 | else 171 | echo "❌ Validation failed" 172 | fi 173 | echo "::endgroup::" 174 | ############################################################################### 175 | 176 | if [ -z "${VALIDATION}" ]; then 177 | exit 1; 178 | fi 179 | 180 | ############################################################################### 181 | echo "::group::🐳 Running Container" 182 | CMD="${CONTAINER_RUNTIME} run -d ${CONTAINER_ARGS} ${CONTAINER_IMAGE}" 183 | echo "${CMD}" 184 | # Run Docker container 185 | eval "${CMD}" 186 | echo "::endgroup::" 187 | ############################################################################### 188 | 189 | ############################################################################### 190 | echo "::group::⏰ Waiting for database to be ready" 191 | DB_IS_UP="" 192 | EXIT_VALUE=0 193 | 194 | for ((COUNTER=1; COUNTER <= HEALTH_MAX_RETRIES; COUNTER++)) 195 | do 196 | echo " - try #${COUNTER} of ${HEALTH_MAX_RETRIES}" 197 | sleep "${HEALTH_INTERVAL}" 198 | DB_IS_UP=$("${CONTAINER_RUNTIME}" exec "${CONTAINER_NAME}" healthcheck.sh && echo "yes" || echo "no") 199 | if [ "${DB_IS_UP}" = "yes" ]; then 200 | break 201 | fi 202 | done 203 | 204 | echo "::endgroup::" 205 | # Start a new group so that database readiness or failure is visible in actions. 206 | 207 | if [ "${DB_IS_UP}" = "yes" ]; then 208 | echo "::group::✅ Database is ready!" 209 | else 210 | echo "::group::❌ Database failed to start on time." 211 | echo "🔎 Container logs:" 212 | "${CONTAINER_RUNTIME}" logs "${CONTAINER_NAME}" 213 | EXIT_VALUE=1 214 | fi 215 | 216 | echo "::endgroup::" 217 | ############################################################################### 218 | exit ${EXIT_VALUE} 219 | --------------------------------------------------------------------------------