diff --git a/.github/workflows/create-wth-release-common.yml b/.github/workflows/create-wth-release-common.yml new file mode 100644 index 0000000000..98c285c256 --- /dev/null +++ b/.github/workflows/create-wth-release-common.yml @@ -0,0 +1,59 @@ +name: Create a WTH Release - Common + +on: + workflow_call: + inputs: + hackathonNames: + description: "The name of the hackathon to create a release for" + required: true + type: string + pathToStudentResources: + description: "The path to the Student Resources directory." + required: true + type: string + branchName: + description: "The name of the branch to create the release from." + required: true + type: string + +jobs: + package: + strategy: + matrix: + hackathonName: ${{ fromJSON(inputs.hackathonNames) }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: echo "TAG=${{ matrix.hackathonName }}" >> $GITHUB_ENV + name: Set tag + - run: | + OUTPUT=0 + gh release view ${{ env.TAG }} || OUTPUT=$? + if [[ $OUTPUT -ne 0 ]]; then + echo "Release not found, continuing..." + else + echo "Release found, deleting..." + gh release delete ${{ env.TAG }} --cleanup-tag --yes + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: Delete ${{ env.TAG }} release if it exists + - run: | + cd ${{ matrix.hackathonName }}/${{ inputs.pathToStudentResources }} + zip -r ${{ env.RESOURCES_FILENAME }} * + + gh release create ${{ env.TAG }} \ + --title "Student Resources for ${{ matrix.hackathonName }}" \ + --notes "Student Resources for ${{ matrix.hackathonName }}" \ + --target ${{ inputs.branchName }} + + gh release upload ${{ env.TAG }} ${{ env.RESOURCES_FILENAME }}.zip + + gh release edit ${{ env.TAG }} --draft=false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RESOURCES_FILENAME: Resources + name: Create ${{ env.TAG }} release diff --git a/.github/workflows/create-wth-release-push.yml b/.github/workflows/create-wth-release-push.yml new file mode 100644 index 0000000000..8d5ef591a1 --- /dev/null +++ b/.github/workflows/create-wth-release-push.yml @@ -0,0 +1,44 @@ +name: Create a WTH Release - Push + +on: + push: + branches: + - master + +jobs: + determine-changed-hackathon: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + all_changed_hackathons: ${{ steps.convert-to-json-array.outputs.all_changed_hackathons }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Get changed hackathons + id: changed-hackathon-directories + uses: tj-actions/changed-files@25ef3926d147cd02fc7e931c1ef50772bbb0d25d + with: + dir_names: true + dir_names_exclude_current_dir: true + dir_names_max_depth: 1 + files: + '**/Student/Resources/**' + files_ignore: | + .github/** + 000-HowToHack/** + _layouts/** + _assets/** + - name: Convert space-separated string to JSON array + id: convert-to-json-array + run: | + JSON_ARRAY=$(echo ${{ steps.changed-hackathon-directories.outputs.all_changed_files }} | tr -d '\n' | jq -R -s -c 'split(" ")') + echo "all_changed_hackathons=$JSON_ARRAY" >> $GITHUB_OUTPUT + package: + needs: determine-changed-hackathon + if: ${{ needs.determine-changed-hackathon.outputs.all_changed_hackathons != '[]' }} + uses: ./.github/workflows/create-wth-release-common.yml + with: + hackathonNames: ${{ needs.determine-changed-hackathon.outputs.all_changed_hackathons }} + pathToStudentResources: 'Student/Resources' + branchName: release \ No newline at end of file diff --git a/.github/workflows/create-wth-release-workflow_dispatch.yml b/.github/workflows/create-wth-release-workflow_dispatch.yml new file mode 100644 index 0000000000..11bfabff0f --- /dev/null +++ b/.github/workflows/create-wth-release-workflow_dispatch.yml @@ -0,0 +1,41 @@ +name: Create a WTH Release - Manual + +on: + workflow_dispatch: + inputs: + hackathonName: + description: "The name of the hackathon to create a release for" + required: true + default: "001-IntroToKubernetes" + pathToStudentResources: + description: "The path to the Student Resources directory." + required: true + default: "Student/Resources" + branchName: + description: "The name of the branch to create the release from." + required: true + default: "master" + +jobs: + determine-changed-hackathon: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + all_changed_hackathons: ${{ steps.convert-to-json-array.outputs.all_changed_hackathons }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Convert space-separated string to JSON array + id: convert-to-json-array + run: | + JSON_ARRAY=$(echo ${{ inputs.hackathonName }} | tr -d '\n' | jq -R -s -c 'split(" ")') + echo "::set-output name=all_changed_hackathons::$JSON_ARRAY" + package: + needs: determine-changed-hackathon + uses: ./.github/workflows/create-wth-release-common.yml + with: + hackathonNames: ${{ needs.determine-changed-hackathon.outputs.all_changed_hackathons }} + pathToStudentResources: ${{ inputs.pathToStudentResources }} + branchName: ${{ inputs.branchName }} + diff --git a/.github/workflows/create-wth-release.yml b/.github/workflows/create-wth-release.yml deleted file mode 100644 index aa076f9314..0000000000 --- a/.github/workflows/create-wth-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Create a release for a WhatTheHack hackathon - -on: - workflow_dispatch: - inputs: - hackathonName: - description: "The name of the hackathon to create a release for" - required: true - default: "001-IntroToKubernetes" - pathToStudentResources: - description: "The path to the Student Resources directory." - required: true - default: "Student/Resources" - branchName: - description: "The name of the branch to create the release from." - required: true - default: "master" - -jobs: - package: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - run: echo "TAG=${{ inputs.hackathonName }}-$(date +'%Y.%m.%d')" >> $GITHUB_ENV - - run: | - cd ${{ inputs.hackathonName }}/${{ inputs.pathToStudentResources }} - zip -r ${{ env.RESOURCES_FILENAME }} * - - gh release create ${{ env.TAG }} \ - --title "Student Resources for ${{ inputs.hackathonName }}" \ - --notes "Student Resources for ${{ inputs.hackathonName }}" \ - --target ${{ inputs.branchName }} - - gh release upload ${{ env.TAG }} ${{ env.RESOURCES_FILENAME }}.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RESOURCES_FILENAME: Resources diff --git a/.gitignore b/.gitignore index c2fd5482d4..95da724773 100644 --- a/.gitignore +++ b/.gitignore @@ -333,4 +333,6 @@ ASALocalRun/ .mfractor/ .DS_Store -.env \ No newline at end of file +.env + +.vscode/ \ No newline at end of file diff --git a/000-HowToHack/WTH-HowToHostAHack.md b/000-HowToHack/WTH-HowToHostAHack.md index 35951da746..20534810eb 100644 --- a/000-HowToHack/WTH-HowToHostAHack.md +++ b/000-HowToHack/WTH-HowToHostAHack.md @@ -204,7 +204,11 @@ You should also upload both the Event Kickoff presentation and any lecture prese ##### Student Resources export tool -You can use the **Create a release for a WhatTheHack hackathon** GitHub Action to make it easier to export just the `Student/Resources` directory as a ZIP file. This will create a release in the repo with the ZIP file as an asset. You can then download the ZIP file and upload it to the General channel's Files tab. +Many hacks will already have a GitHub Release ZIP file which includes the hack's `Student/Resources` directory. You can use this ZIP file directly if you don't need to make any changes to the hack (a GitHub Action will create this ZIP file on each push to the `master` branch, so the ZIP file should be up-to-date with the latest changes). + +![releases-resources-zip-file](images/releases-resources-zip-file.png) + +If the ZIP file doesn't exist or you need to make changes to the content in the repo, you can use the **Create a WTH Release - Manual** GitHub Action to make it easier to export just the `Student/Resources` directory as a ZIP file. This will create a release in the repo with the ZIP file as an asset. You can then download the ZIP file and upload it to the General channel's Files tab. Here are the steps to use the tool to export the Student Resources: @@ -227,8 +231,6 @@ Here are the steps to use the tool to export the Student Resources: 1. Expand the **Assets** section. 1. Click on the **Resources.zip** file to download it. - ![releases-resources-zip-file](images/releases-resources-zip-file.png) - #### Shared Tips/Wiki (Optional) During a What The Hack event, attendees are strongly encouraged to share knowledge and learn from each other. Knowledge sharing is encouraged across the entire event, including between squads. diff --git a/000-HowToHack/images/create-a-release-for-a-whatthehack-hackathon.png b/000-HowToHack/images/create-a-release-for-a-whatthehack-hackathon.png index fe7fdfb485..45c544280a 100644 Binary files a/000-HowToHack/images/create-a-release-for-a-whatthehack-hackathon.png and b/000-HowToHack/images/create-a-release-for-a-whatthehack-hackathon.png differ