diff --git a/README.md b/README.md index e4fd7c2..0e57a58 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ The actions are used by Elysium to run CI/CD tasks and this repo will be archive The actions available are: - [S3 Backup](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/s3-backup/action.yml) -- [Oasis Deploy](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/oasis-deploy/action.yml) +- [Oasis Auto Setup](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/oasis-setup-auto/action.yml) - [Infisical Env](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/infisical-env/action.yml) +- [Oasis Advanced Setup](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/oasis-setup-advanced/action.yml) - [Elysium CI/CD](https://gitea.dunemask.dev/elysium/elysium-actions/src/branch/elysium-ci-cd/action.yml) ## Workflow Template diff --git a/action.yml b/action.yml index 43b45c4..da6cea8 100644 --- a/action.yml +++ b/action.yml @@ -1,46 +1,80 @@ -name: "S3 Backup Action" -description: "Backup to S3 Bucket" +name: Oasis Auto Config Action +description: Configure env for deploying apps using Oasis Automagically inputs: infisical-token: - description: Infisical token for backup envars + description: Infisical token for CI or Edge required: true infisical-project: - description: Infisical Project + description: Infisical Project For Secrets required: true - s3-backup-path: - description: "Workspace to setup Oasis" + deploy-env: + description: Deploy Environment (ci or edge) + required: true + kubeconfig: + description: Kubeconfig for Oasis required: false - default: backups/forgejo-repositories/${{ gitea.repository }} + extra-secret-paths: + description: Additional Secrets to fetch + required: false + extra-secret-envs: + description: Additional Envs for secrets to fetch + required: false + garden-version: + description: Version of Garden to deploy + required: false + 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" + using: composite steps: - # Checkout Repository - - name: Checkout Repository - uses: actions/checkout@v3 - with: - path: repo - # Load Backup Envars - - name: Setup Backup Envars + - name: Configure Workflow + shell: bash + run: | + if [ ${{ inputs.deploy-env }} == "edge" ]; then + WORKFLOW_SECRET=/workflows/oasis-edge-deploy,/workflows/discord + elif [ ${{ inputs.deploy-env }} == "ci" ]; then + WORKFLOW_SECRET=/workflows/oasis-ci-deploy,/workflows/discord + else + echo "Error! deploy-env required, and must be 'ci' or 'edge'!" + exit 1 + fi + # Save Envars + echo OASIS_INFISICAL_TOKEN=${{ inputs.infisical-token }} >> $GITHUB_ENV + echo OASIS_PATH_FETCH=$WORKFLOW_SECRET,${{ inputs.extra-secret-paths }} >> $GITHUB_ENV # /workflows/oasis--deploy, ...extra-secret-paths + echo OASIS_ENV_FETCH=${{ inputs.deploy-env }},${{inputs.deploy-env}},${{ inputs.extra-secret-envs }} >> $GITHUB_ENV #, ...extra-secret-envs + - name: Setup Oasis Envars uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env with: - infisical-token: ${{ inputs.infisical-token }} + infisical-token: ${{ env.OASIS_INFISICAL_TOKEN }} project-id: ${{ inputs.infisical-project }} - secret-envs: edge - secret-paths: /devops/forgejo-backups - # Fix Envar Format - - name: Fix Env Format + secret-envs: ${{ env.OASIS_ENV_FETCH }} + secret-paths: ${{ env.OASIS_PATH_FETCH }} + - name: Configure Kubeconfig + shell: bash run: | - echo BACKUP_S3_ENDPOINT=${{ env.DEVOPS_FORGEJO_ELYSIUM_ORG_S3_ENDPOINT }} >> $GITHUB_ENV - echo BACKUP_S3_KEY_ID=${{ env.DEVOPS_FORGEJO_ELYSIUM_ORG_S3_KEY_ID }} >> $GITHUB_ENV - echo BACKUP_S3_KEY=${{ env.DEVOPS_FORGEJO_ELYSIUM_ORG_S3_KEY }} >> $GITHUB_ENV - # Backup Repository - - name: S3 Backup - uses: https://github.com/peter-evans/s3-backup@v1 - env: - STORAGE_SERVICE_URL: ${{ env.BACKUP_S3_ENDPOINT }} - ACCESS_KEY_ID: ${{ env.BACKUP_S3_KEY_ID }} - SECRET_ACCESS_KEY: ${{ env.BACKUP_S3_KEY }} - MIRROR_TARGET: ${{ inputs.s3-backup-path }} - MIRROR_SOURCE: repo + if [ -n "${{ inputs.kubeconfig }}" ] && [ "${{ inputs.kubeconfig }}" != "" ]; then + echo "Using Provided Kubernetes Config" + echo OASIS_WORKFLOW_KUBECONFIG=${{ inputs.kubeconfig }} >> $GITHUB_ENV + elif [ "${{ inputs.deploy-env }}" == "edge" ]; then + echo "Using Edge Kubernetes Config" + echo OASIS_WORKFLOW_KUBECONFIG=${{env.KUBERNETES_CONFIG_USW_EDGE}} >> $GITHUB_ENV + elif [ "${{ inputs.deploy-env }}" == "ci" ]; then + echo "Using Dev Kubernetes Config" + echo OASIS_WORKFLOW_KUBECONFIG=${{env.KUBERNETES_CONFIG_USW_DEV}} >> $GITHUB_ENV + else + echo "Error! deploy-env required, and must be 'ci' or 'edge'!" + exit 1 + fi + - name: Oasis Setup + uses: https://forgejo.dunemask.dev/elysium/elysium-actions@oasis-setup-advanced with: - args: --overwrite --remove + garden-version: ${{ inputs.garden-version }} + oasis-branch: ${{ inputs.oasis-branch }} + oasis-workspace: ${{ inputs.oasis-workspace }} + kubeconfig: ${{ env.OASIS_WORKFLOW_KUBECONFIG }}