|
| 1 | +name: test-maven-setup-action |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-16.04 |
| 10 | + name: test maven-setup action |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + |
| 15 | + with: |
| 16 | + java-version: '13' |
| 17 | + - uses: actions/cache@v1 |
| 18 | + with: |
| 19 | + path: ~/.m2 |
| 20 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 21 | + restore-keys: | |
| 22 | + ${{ runner.os }}-maven- |
| 23 | + - run: env | sort |
| 24 | + - uses: navikt/bidrag-maven/setup@main |
| 25 | + with: |
| 26 | + repositories: maven-releases=https://repo.releases,snapshots=https://repo.snapshots |
| 27 | + env: |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + - run: mvn help:effective-pom |
| 30 | + - name: Verify .m2 home |
| 31 | + run: | |
| 32 | + POM=$(cat ~/.m2/settings.xml) |
| 33 | + echo $POM |
| 34 | + echo count number of repos |
| 35 | + COUNT_REPOS=$(echo $POM | grep -c https://repo) |
| 36 | +
|
| 37 | + echo count number of maven-releases |
| 38 | + COUNT_NAME_MAVEN=$(echo $POM | grep -c maven-releases) |
| 39 | +
|
| 40 | + echo count number of snapshots |
| 41 | + COUNT_NAME_SNAP=$(echo $POM | grep -c snapshots) |
| 42 | +
|
| 43 | + echo count number of github actor |
| 44 | + COUNT_ACTOR=$(echo $POM | grep -c $GITHUB_ACTOR) |
| 45 | +
|
| 46 | + echo count number of github tokens |
| 47 | + COUNT_TOKEN=$(echo $POM | grep -c $GITHUB_TOKEN) |
| 48 | +
|
| 49 | + # FOR SOME REASON, ONLY COUNTS ONE???? |
| 50 | + echo check number of repos |
| 51 | + if [[ $COUNT_REPOS -ne 1 ]]; then |
| 52 | + echo ::error:: $COUNT_REPOS is not expected 2 repositories urls from the settings.xml |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + # FOR SOME REASON, ONLY COUNTS ONE???? |
| 57 | + echo check number of maven-releases |
| 58 | + if [[ $COUNT_NAME_MAVEN -ne 1 ]]; then |
| 59 | + echo ::error:: expected maven-releases to occur for server/repo id and repo name in the settings.xml, but found: $COUNT_NAME_MAVEN |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | +
|
| 63 | + # FOR SOME REASON, ONLY COUNTS ONE???? |
| 64 | + echo check number of snapshots |
| 65 | + if [[ $COUNT_NAME_SNAP -ne 1 ]]; then |
| 66 | + echo ::error:: could not find name snapshots to occur for server/repo id and repo name in the settings.xml, but found: $COUNT_NAME_SNAP |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | +
|
| 70 | + # FOR SOME REASON, ONLY COUNTS ONE???? |
| 71 | + echo check number of github actor |
| 72 | + if [[ $COUNT_ACTOR -ne 1 ]]; then |
| 73 | + echo ::error:: could not find github actor as username for each repository, but found: $COUNT_ACTOR |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + # FOR SOME REASON, ONLY COUNTS ONE???? |
| 78 | + echo check number of github tokens |
| 79 | + if [[ $COUNT_TOKEN -ne 1 ]]; then |
| 80 | + echo ::error:: could not find github token as password for each repository, but found: $COUNT_TOKEN |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments