Logo von GitHub

© GitHub Inc.

I'm used to maintain my own instance of Claus Due's wonderful fluidtypo3-gizzle application in order to deploy my TYPO3 extensions to TER (the TYPO3 extesion repository), but ran into issues when migrating this to a new server lately.

 

As I'm playing around with Github Actions based tests for a few weeks now, I quickly thought about using a Github Action workflow for pushing TER releases too! It's quite easy when using existing tools like (again: Claus Due!) typo3-repository-client.

 

This works similar to what I had before: pushing a new GIT tag will trigger uploading a new version to TER. With GitHub Actions there is no need for a webhook, triggering an endpoint (my own fluidtypo3-gizzle instance), which triggers the upload using typo3-repository-client, but using the repo client directly in our workflow file.

 

Let's see how to configure that:

jobs:

  # Do some testing!
  tests:
    ...

  tag-valid:
    name: Check for valid tag

    # Run only if tests job is successful
    needs: tests
    # Run only if it's a tag in general (as regex is not possible here)
    if: startsWith(github.ref, 'refs/tags/')

    runs-on: ubuntu-latest

    # Save status for use in other jobs
    outputs:
      status: ${{ steps.check-tag.outputs.match }}

    steps:
      # Check for a valid tag
      - name: Check if trigger is a valid tag
        id: check-tag
        run: |
          if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            echo ::set-output name=match::true
          fi
TER deployment Github action: tag valid job

The tag-valid job will run only if the tests job has been finished successfully and checks if the trigger event is a valid tag. Use a custom regex to match your naming scheme and add additional checks if required.

jobs:

  tests:
    ...

  tag-valid:
    ...

  ter-release:
    name: TYPO3 TER release

    # Depend on a valid tag
    needs: tag-valid
    if: needs.tag-valid.outputs.status == 'true'

    runs-on: ubuntu-latest
    strategy:
      matrix:
        php-versions: [7.4]

    env:
      # Add your extension key
      TYPO3_EXTENSION_KEY: your_extension_key
      TYPO3_USER: ${{ secrets.TYPO3_USER }}
      TYPO3_PASSWORD: ${{ secrets.TYPO3_PASSWORD }}

    steps:
      - uses: actions/checkout@v2
        with:
          path: ${{ env.TYPO3_EXTENSION_KEY }}

      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-versions }}
          extensions: intl, mbstring, xml, soap, zip, curl

      - name: Install TYPO3 TER client
        run: composer global require namelesscoder/typo3-repository-client "^2.0" --prefer-dist --no-progress --no-suggest

      - name: Remove .git folder
        run: rm -rf ./$TYPO3_EXTENSION_KEY/.git

      - name: Upload EXT:${{ env.TYPO3_EXTENSION_KEY }} as ${{ github.event.ref }} to TER
        run: php ~/.composer/vendor/bin/upload "./$TYPO3_EXTENSION_KEY" "$TYPO3_USER" "$TYPO3_PASSWORD" "${{ github.event.head_commit.message }}"
TER deployment Github action: TER release job

The ter-release job will only run if the valid-tag job has been finished successfully (as in the job ran successfully AND the tag is valid). If so, the job will setup PHP with some needed extensions, checkout the actual extension code, install the TER client globally, delete the .git folder and then run the upload command.

 

In order to make the actual TER upload work, you will need to configure your extension key and add your typo3.org SSO credentials as secrets to the Github repository.

 

 

Please see my testing repo for a complete example file and documentation:

https://github.com/fnagel/typo3-ter-release-github-action

Die Kommentarfunktion ist für diesen Artikel deaktiviert.

0 Kommentare