openrewrite / rewrite-github-actions

OpenRewrite recipes for performing GitHub action hygiene and migration tasks.
Apache License 2.0
9 stars 9 forks source link

Recipe - Extract reusable workflow #76

Open aalmiray opened 1 year ago

aalmiray commented 1 year ago

Given a set of similar workflows such as those found at https://github.com/asyncer-io/r2dbc-mysql/tree/f4ca1652219074c337d7db12d2572686da2c3a64/.github/workflows where 3 workflows are almost identical except for 1 property

name: MySQL 5.7

on: [ pull_request ]

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
      - name: Set up Temurin 8
        uses: actions/setup-java@v3
        with:
          distribution: temurin
          java-version: 8
          cache: maven
      - name: Shutdown the Default MySQL
        run: sudo service mysql stop
      - name: Set up MySQL 5.7
        uses: asyncer-io/mysql-action@trunk
        with:
          # THIS IS THE SINGLE VALUE THAT'S DIFFERENT
          mysql version: 5.7
          mysql database: r2dbc
          mysql root password: r2dbc-password!@
      - name: Integration test with MySQL 5.7
        run: ./mvnw -B verify -Dmaven.javadoc.skip=true -Dmaven.surefire.skip=true -Dtest.mysql.password=r2dbc-password!@ -Dtest.mysql.version=5.7 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
sambsnyd commented 1 year ago

Is what you're asking for a recipe which analyzes many different workflows, keeps the commonalities, and parameterizes the differences? That sounds quite complex to solve in the general case.

aalmiray commented 1 year ago

Yes, that's an accurate summary 😅