Skip to content

Commit

Permalink
Merge pull request #4 from MathieuSoysal/3-add-selector-on-tags
Browse files Browse the repository at this point in the history
3 add selector on tags
  • Loading branch information
MathieuSoysal authored Feb 15, 2023
2 parents 5fc790f + b8a657c commit 6e051c6
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/test-action-final.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ jobs:
command_line: cat tests/test2.txt
contains: MathieuSoysal/[email protected]

- 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:
Expand Down Expand Up @@ -47,3 +52,24 @@ jobs:
with:
command_line: cat tests/test2.txt
contains: MathieuSoysal/[email protected]



# 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
30 changes: 28 additions & 2 deletions .github/workflows/test-action-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ jobs:
command_line: cat tests/test2.txt
contains: MathieuSoysal/[email protected]

- 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
Expand All @@ -43,4 +48,25 @@ jobs:
uses: GuillaumeFalourd/assert-command-line-output@v2
with:
command_line: cat tests/test2.txt
contains: MathieuSoysal/[email protected]
contains: MathieuSoysal/[email protected]



# 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
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tests/test-maven.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6e051c6

Please sign in to comment.