Skip to content

Commit

Permalink
ci: preserves filter before deletion for java (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
valmoz authored Apr 4, 2022
1 parent 1de6c2e commit be826eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/generate-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '11'

- id: setup-libraries
name: Install libraries
Expand Down Expand Up @@ -87,6 +87,12 @@ jobs:
echo "sdk_version=$SDK_VERSION" >> $GITHUB_ENV
echo "openapi_version=$OPENAPI_VERSION" >> $GITHUB_ENV
- id: move-custom-files-to-backup
name: Move custom files to backup
run: |
mkdir -p ./backup/java/src/main/java/it/fattureincloud/sdk/
mv ./generated/java/src/main/java/it/fattureincloud/sdk/filter ./backup/java/src/main/java/it/fattureincloud/sdk/filter
- id: delete-old-files
name: Delete old files
run: |
Expand Down Expand Up @@ -137,15 +143,23 @@ jobs:
openapi-generator-cli generate -i ./openapi.yaml -g java -o ./generated/java/ -t ./templates/java --git-repo-id=${GIT_REPO_ID} --git-user-id=${GIT_USER_ID} --release-note=${RELEASE_NOTE} --http-user-agent=${USER_AGENT} --additional-properties=$ADDITIONAL_PROPERTIES
- id: move-custom-files-to-repo
name: Move custom files to repo
run: |
mv ./backup/java/src/main/java/it/fattureincloud/sdk/filter ./generated/java/src/main/java/it/fattureincloud/sdk/filter
- id: download-linter
name: Download Java Linter
run: |
LAST_VERSION_LINK = curl -s https://api.github.com/repos/google/google-java-format/releases/latest | jq -r ".assets[] | select(.name | test(\"all-deps\")) | .browser_download_url"
curl ${LAST_VERSION_LINK} -o linter.jar
LAST_VERSION_LINK=$(curl -s https://api.github.com/repos/google/google-java-format/releases/latest | jq -r ".assets[] | select(.name | test(\"all-deps\")) | .browser_download_url")
curl ${LAST_VERSION_LINK} -L -o linter.jar
- id: format-code
name: Format Code
run: java -jar ./linter.jar --replace ./generated/java/**/*.java
working-directory: ./generated/java
run: |
java -jar ../../linter.jar --replace ./src/main/java/it/fattureincloud/sdk/**/*.java
java -jar ../../linter.jar --replace ./src/main/java/it/fattureincloud/sdk/*.java
- id: create-pr
name: Create Pull Request
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/generate-php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ jobs:
echo "sdk_version=$SDK_VERSION" >> $GITHUB_ENV
echo "openapi_version=$OPENAPI_VERSION" >> $GITHUB_ENV
- id: move-custom-files-to-backup
name: Move custom files to backup
run: |
mkdir -p ./backup/php/lib/Filter
mv ./generated/php/lib/Filter ./backup/php/lib/
- id: delete-old-files
name: Delete old files
run: |
Expand All @@ -111,6 +117,11 @@ jobs:
node ./scripts/postprocess-php.js clean './generated/php/lib/' './generated/php/test/'
- id: move-custom-files-to-repo
name: Move custom files to repo
run: |
mv ./backup/php/lib/Filter ./generated/php/lib/Filter
- id: create-pr
name: Create Pull Request
uses: peter-evans/create-pull-request@v3
Expand Down

0 comments on commit be826eb

Please sign in to comment.