From ab33ac65436c5a836b7c934d7bfec0f01c3dea27 Mon Sep 17 00:00:00 2001 From: Graham Dumpleton Date: Wed, 6 Sep 2023 12:59:00 +1000 Subject: [PATCH] Replace GitHub workflow with multi workshop variant. --- .github/workflows/publish-workshop.yaml | 22 -------- .github/workflows/publish-workshops.yaml | 72 ++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/publish-workshop.yaml create mode 100644 .github/workflows/publish-workshops.yaml diff --git a/.github/workflows/publish-workshop.yaml b/.github/workflows/publish-workshop.yaml deleted file mode 100644 index 753f07a..0000000 --- a/.github/workflows/publish-workshop.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Publish Workshop - -on: - push: - tags: - - "[0-9]+.[0-9]+" - - "[0-9]+.[0-9]+-alpha.[0-9]+" - - "[0-9]+.[0-9]+-beta.[0-9]+" - - "[0-9]+.[0-9]+-rc.[0-9]+" - -jobs: - publish-workshop: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Create release - uses: vmware-tanzu-labs/educates-github-actions/publish-workshop@v6 - with: - token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/publish-workshops.yaml b/.github/workflows/publish-workshops.yaml new file mode 100644 index 0000000..bc0c02c --- /dev/null +++ b/.github/workflows/publish-workshops.yaml @@ -0,0 +1,72 @@ +name: Publish Workshops + +on: + push: + tags: + - "[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+-alpha.[0-9]+" + - "[0-9]+.[0-9]+-beta.[0-9]+" + - "[0-9]+.[0-9]+-rc.[0-9]+" + +jobs: + publish-workshops: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Carvel tools + shell: bash + run: curl -L https://carvel.dev/install.sh | bash + + - name: Install Educates CLI + shell: bash + run: | + # curl -Lo /usr/local/bin/educates https://github.com/vmware-tanzu-labs/educates-training-platform/releases/download/2.6.0-alpha.31/educates-linux-amd64 + # chmod +x /usr/local/bin/educates + imgpkg pull -i ghcr.io/vmware-tanzu-labs/educates-client-programs:2.6.0-alpha.31 -o /tmp/client-programs + mv /tmp/client-programs/educates-linux-amd64 /usr/local/bin/educates + + - name: Setup repository variables and release details + shell: bash + run: | + echo REPOSITORY_OWNER=$(echo "${{github.repository_owner}}" | tr '[:upper:]' '[:lower:]') >>${GITHUB_ENV} + echo REPOSITORY_NAME=${{github.event.repository.name}} >>${GITHUB_ENV} + echo REPOSITORY_TAG=$(echo "${{github.ref}}" | sed -e 's%refs/tags/%%') >>${GITHUB_ENV} + + - name: Publish workshops and create workshop definitions + shell: bash + run : | + for WORKSHOP_DIRECTORY in workshops/*; do + mkdir -p ${{runner.temp}}/${WORKSHOP_DIRECTORY}/resources + educates publish-workshop ${WORKSHOP_DIRECTORY} \ + --export-workshop ${{runner.temp}}/${WORKSHOP_DIRECTORY}/resources/workshop.yaml \ + --image-repository=ghcr.io/${REPOSITORY_OWNER} \ + --workshop-version=${REPOSITORY_TAG} \ + --registry-username=${{github.actor}} \ + --registry-password=${{secrets.GITHUB_TOKEN}} + done + + - name: Generate archives containing the workshop definitions + shell: bash + run: | + ytt -f ${{runner.temp}}/workshops > ${{runner.temp}}/workshops.yaml + (cd ${{runner.temp}}; tar cvfz workshops.tar.gz workshops) + (cd ${{runner.temp}}; zip workshops.zip -r workshops) + + - name: Create the GitHub release for the workshops + id: create_release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + tag_name: ${{env.REPOSITORY_TAG}} + name: ${{env.REPOSITORY_NAME}}:${{env.REPOSITORY_TAG}} + draft: false + prerelease: false + files: | + ${{runner.temp}}/workshops.tar.gz + ${{runner.temp}}/workshops.zip + ${{runner.temp}}/workshops.yaml + resources/trainingportal.yaml