actions-release-trigger #60
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "React on Magellan client release" | |
| on: | |
| repository_dispatch: | |
| types: [actions-release-trigger] | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| # Default to bash | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| env: | |
| HUGO_VERSION: 0.138.0 | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v4 | |
| - name: "Update Releases" | |
| run: | | |
| set -x | |
| git checkout master | |
| git config user.name "$GITHUB_ACTOR" | |
| git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
| VERSION=${{ github.event.client_payload.version }} | |
| BUILD=${{ github.event.client_payload.build }} | |
| TYPE=${{ github.event.client_payload.type }} | |
| ACTION=${{ github.event.client_payload.action }} | |
| if [[ "$TYPE" == "stable" ]]; then | |
| # define client version | |
| FILE=static/api/versions/index.json | |
| CURRENT_RELEAE_VERSION_NUMBERS=( ${VERSION//./ } ) | |
| RELEASE_VERSION_MAJOR=${CURRENT_RELEAE_VERSION_NUMBERS[0]} | |
| RELEASE_VERSION_MINOR=${CURRENT_RELEAE_VERSION_NUMBERS[1]} | |
| RELEASE_VERSION_PATCH=${CURRENT_RELEAE_VERSION_NUMBERS[2]} | |
| echo "{" > $FILE | |
| echo " \"versions\": {" >> $FILE | |
| echo " \"latest\": {" >> $FILE | |
| echo " \"raw\": \"${VERSION}\"," >> $FILE | |
| echo " \"major\": \"${RELEASE_VERSION_MAJOR}\"," >> $FILE | |
| echo " \"minor\": \"${RELEASE_VERSION_MINOR}\"," >> $FILE | |
| echo " \"revision\": \"${RELEASE_VERSION_PATCH}\"," >> $FILE | |
| echo " \"pre\": \"${BUILD}\"," >> $FILE | |
| echo " \"build\": \"${BUILD}\"," >> $FILE | |
| echo " \"type\": \"\"" >> $FILE | |
| echo " }," >> $FILE | |
| echo " \"stable\": {" >> $FILE | |
| echo " \"raw\": \"${VERSION}\"," >> $FILE | |
| echo " \"major\": \"${RELEASE_VERSION_MAJOR}\"," >> $FILE | |
| echo " \"minor\": \"${RELEASE_VERSION_MINOR}\"," >> $FILE | |
| echo " \"revision\": \"${RELEASE_VERSION_PATCH}\"," >> $FILE | |
| echo " \"pre\": \"${BUILD}\"," >> $FILE | |
| echo " \"build\": \"${BUILD}\"," >> $FILE | |
| echo " \"type\": \"\"" >> $FILE | |
| echo " }" >> $FILE | |
| echo " }" >> $FILE | |
| echo "}" >> $FILE | |
| git add $FILE | |
| elif [[ "$TYPE" == "plugins" ]]; then | |
| # define plugin version | |
| FILE=static/api/versions/plugins.json | |
| CURRENT_RELEAE_VERSION_NUMBERS=( ${VERSION//./ } ) | |
| RELEASE_VERSION_MAJOR=${CURRENT_RELEAE_VERSION_NUMBERS[0]} | |
| RELEASE_VERSION_MINOR=${CURRENT_RELEAE_VERSION_NUMBERS[1]} | |
| RELEASE_VERSION_PATCH=${CURRENT_RELEAE_VERSION_NUMBERS[2]} | |
| echo "{" > $FILE | |
| echo " \"versions\": {" >> $FILE | |
| echo " \"plugins\": {" >> $FILE | |
| echo " \"raw\": \"${VERSION}\"," >> $FILE | |
| echo " \"major\": \"${RELEASE_VERSION_MAJOR}\"," >> $FILE | |
| echo " \"minor\": \"${RELEASE_VERSION_MINOR}\"," >> $FILE | |
| echo " \"revision\": \"${RELEASE_VERSION_PATCH}\"" >> $FILE | |
| echo " }" >> $FILE | |
| echo " }" >> $FILE | |
| echo "}" >> $FILE | |
| git add $FILE | |
| else | |
| ACTION="test" | |
| fi | |
| if [[ "$ACTION" == "test" ]]; then | |
| echo "just testing" | |
| cat $FILE | |
| else | |
| git commit -m "chore: triggered new $TYPE release version ${VERSION}" | |
| REMOTE="https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" | |
| git push "$REMOTE" | |
| fi | |
| - name: "Install Hugo CLI" | |
| run: | | |
| wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
| && sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
| - name: "Install Dart Sass" | |
| run: sudo snap install dart-sass | |
| - name: "Setup Pages" | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| - name: "Build with Hugo" | |
| env: | |
| HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache | |
| HUGO_ENVIRONMENT: production | |
| run: | | |
| hugo \ | |
| --baseURL "${{ steps.pages.outputs.base_url }}/" | |
| cp public/de/404.html public/404.html | |
| - name: "Upload artifact" | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./public | |
| # Deployment job | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: "Deploy to GitHub Pages" | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |