diff --git a/.github/workflows/custom-artifact.yml b/.github/workflows/custom-artifact.yml index 8dfb6bc25..9a246a77a 100644 --- a/.github/workflows/custom-artifact.yml +++ b/.github/workflows/custom-artifact.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: offline: - name: Prepare custom offline package + name: Prepare custom offline package # Do not change this name, it is used to trigger deploy-wiab workflow # Useful to skip expensive CI when writing docs if: "!contains(github.event.head_commit.message, 'skip ci')" runs-on: @@ -54,6 +54,11 @@ jobs: env: DOCKER_LOGIN: '${{ secrets.DOCKER_LOGIN }}' + # Set output for deploy-wiab workflow to start + - name: Set output to trigger dependent workflow + if: success() + run: echo "::set-output name=trigger_next_workflow::true" + - name: Deploy offline environment to hetzner run: | ./offline/cd.sh diff --git a/.github/workflows/deploy-wiab.yml b/.github/workflows/deploy-wiab.yml new file mode 100644 index 000000000..861e91d08 --- /dev/null +++ b/.github/workflows/deploy-wiab.yml @@ -0,0 +1,37 @@ +name: Deploy on Hetnzer WIAB setup +on: + workflow_run: + workflows: ["Prepare custom offline package"] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + concurrency: + group: autodeploy-script + cancel-in-progress: false + + steps: + # Step 1: Checkout the repository code + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Set up SSH key for remote access + - name: Set up SSH key + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + # Step 3: Get the latest commit SHA, for the artifact + - name: Get latest commit SHA + id: get_commit_sha + run: | + COMMIT_SHA=$(git rev-parse --short HEAD) + echo "commit_sha=$COMMIT_SHA" >> $GITHUB_ENV + + # Step 4: Run the autodeploy script + - name: Run Auto Deploy Script + run: | + cd bin + ./autodeploy.sh --artifact-hash ${{ env.commit_sha }} --target-domain wiab-test-box.wire.link