diff --git a/.github/workflows/test-action-final.yml b/.github/workflows/test-action-final.yml index 53272b7..2c926d2 100644 --- a/.github/workflows/test-action-final.yml +++ b/.github/workflows/test-action-final.yml @@ -18,8 +18,13 @@ jobs: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.0 + - uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + test-for-github-workflow: # Test the action with the GitHub workflow - name: Test update-readme-files action + name: Test update dependency needs: check-files continue-on-error: true strategy: @@ -47,3 +52,24 @@ jobs: with: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.3 + + + + # Test with a specific kind tag + + - name: Test kind of tag + uses: ./ + with: + files: tests/test-maven.txt + github_repository: GoogleContainerTools/jib + prefix: "cloud.tools:jib-maven-plugin:" + suffix: ":build ." + regex: "[0-9.]*" + selector: maven + + - name: Test if file has been updated + uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + expected_result: FAILED \ No newline at end of file diff --git a/.github/workflows/test-action-local.yml b/.github/workflows/test-action-local.yml index 17b9cc3..7448985 100644 --- a/.github/workflows/test-action-local.yml +++ b/.github/workflows/test-action-local.yml @@ -18,8 +18,13 @@ jobs: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.0 + - uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + test-for-github-workflow: # Test the action with the GitHub workflow - name: Test update-readme-files action + name: Test update dependency needs: check-files continue-on-error: true runs-on: ubuntu-latest @@ -43,4 +48,25 @@ jobs: uses: GuillaumeFalourd/assert-command-line-output@v2 with: command_line: cat tests/test2.txt - contains: MathieuSoysal/file-updater-for-release@v1.0.3 \ No newline at end of file + contains: MathieuSoysal/file-updater-for-release@v1.0.3 + + + + # Test with a specific kind tag + + - name: Test kind of tag + uses: ./ + with: + files: tests/test-maven.txt + github_repository: GoogleContainerTools/jib + prefix: "cloud.tools:jib-maven-plugin:" + suffix: ":build ." + regex: "[0-9.]*" + selector: maven + + - name: Test if file has been updated + uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + expected_result: FAILED \ No newline at end of file diff --git a/action.yml b/action.yml index 4ae44e8..5aa0d47 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,11 @@ inputs: description: "Github repository to get the latest tag" required: true type: string + selector: # selector to get a particular kind of tag in many kind of tags + description: "Selector to get the latest tag" + required: true + default: "" + type: string @@ -47,7 +52,7 @@ runs: id: get_new_tag shell: bash run: | - temp_result=$(curl -s https://api.github.com/repos/${{ inputs.github_repository }}/tags | grep -h "name" | head -1 | grep -ho "${{inputs.regex}}") + temp_result=$(curl -s https://api.github.com/repos/${{inputs.github_repository}}/tags | grep -h "name" | grep -h "${{inputs.selector}}" | head -1 | grep -ho "${{inputs.regex}}") echo "new-tag=${temp_result}" >> $GITHUB_OUTPUT - name: update files diff --git a/tests/test-maven.txt b/tests/test-maven.txt new file mode 100644 index 0000000..b8a9419 --- /dev/null +++ b/tests/test-maven.txt @@ -0,0 +1,21 @@ + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + cache: maven + + - name: Build JIB container and publish to GitHub Packages + run: | + if [ ! -z "${{ inputs.module }}" ]; then + MULTI_MODULE_ARGS="-am -pl ${{ inputs.module }}" + fi + if [ ! -z "${{ inputs.main-class }}" ]; then + MAIN_CLASS_ARGS="-Djib.container.mainClass=${{ inputs.main-class }}" + fi + mvn package com.google.cloud.tools:jib-maven-plugin:3.2.1:build \ + -Djib.to.image=${{ inputs.REGISTRY }}/${{ steps.downcase.outputs.lowercase }}:${{ inputs.tag-name }} \ + -Djib.to.auth.username=${{ inputs.USERNAME }} \ + -Djib.to.auth.password=${{ inputs.PASSWORD }} $MULTI_MODULE_ARGS $MAIN_CLASS_ARGS + shell: bash \ No newline at end of file