From d8cbcaf5c0cbef0962f06353e979c3a12da2755a Mon Sep 17 00:00:00 2001 From: Dunemask Date: Tue, 13 Feb 2024 16:18:53 -0700 Subject: [PATCH] [FEATURE] Oasis Deploy Action --- action.yml | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..fc7abe7 --- /dev/null +++ b/action.yml @@ -0,0 +1,75 @@ +name: 'Oasis Config Action' +description: 'Configure env for deploying apps using Oasis' +inputs: + kubeconfig: + description: 'A base64 encoded string of the kubeconfig to use. Required!' + required: true + gitea-token: + description: 'Gitea token for downloading repositories' + required: true + garden-version: + description: 'Version of Garden to deploy' + required: false + default: 0.13.24 + oasis-branch: + description: 'Branch of Oasis to use' + required: false + default: master + oasis-workspace: + descipriont: 'Workspace to setup Oasis' + required: false + default: ${{ gitea.workspace}}/oasis +runs: + using: "composite" + steps: + # Set additional Envars + - name: Setting Short Commit Sha + run: echo SHORT_COMMIT_SHA=$(echo $GITHUB_SHA | cut -c 1-6) >> $GITHUB_ENV + - name: Setup Enviornment Variables + run: | + echo CI_NAMESPACE=ci-$SHORT_COMMIT_SHA >> $GITHUB_ENV + echo REPO_GITEA_TOKEN_RO=$GITEA_TOKEN >> $GITHUB_ENV + env: + GITEA_TOKEN: ${{ inputs.gitea-token }} + # Checkout Oasis + - name: Checkout Oasis + uses: actions/checkout@v3 + with: + repository: "elysium/oasis" + path: ${{ inputs.oasis-workspace }} + token: ${{ inputs.gitea-token}} + ref: ${{ inputs.oasis-branch }} + - name: Download Garden + shell: bash + env: + GARDEN_BIN_VERSION: ${{ inputs.garden-version }} + GARDEN_DIR: ${{ runner.temp }}/garden + run: | + # Install Garden + mkdir -p "$GARDEN_DIR" + cd "$GARDEN_DIR" + if ! [ -d "$GARDEN_BIN_VERSION" ]; then + echo "Downloading ${GARDEN_BIN_VERSION}..." + if [[ "$GARDEN_BIN_VERSION" = "latest" ]]; then + tag_param="" + else + tag_param="$GARDEN_BIN_VERSION" + fi + fi + curl -sL https://get.garden.io/install.sh | bash -s -- $tag_param + echo PATH=$PATH:$HOME/.garden/bin >> $GITHUB_ENV + git config --global --add safe.directory $HOME/.garden/bin/static + # Configure K&S + - name: Configure K8S + run: | + echo "Setup kubeconfig" + mkdir -p ~/.kube && + echo "${KUBECONFIG_BASE64}" | base64 -d > ~/.kube/config && + chmod 700 ~/.kube/config + env: + KUBECONFIG_BASE64: ${{ inputs.kubeconfig }} + - name: Export Envars + shell: bash + run: | + # Export environment variables + echo OASIS_WORKSPACE=${{ inputs.oasis-workspace }} >> $GITHUB_ENV