|
| 1 | +name: test-maven-setup-action |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - feature/setup |
| 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@feature/setup |
| 25 | + with: |
| 26 | + repositories: maven-releases=http://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 | + COUNT_REPOS=$(echo $POM | grep -c http::/repo || true) |
| 35 | + COUNT_NAME_MAVEN=$(echo $POM | grep -c maven-releases || true) |
| 36 | + COUNT_NAME_SNAP=$(echo $POM | grep -c snapshots || true) |
| 37 | + COUNT_ACTOR=$(echo $POM | grep -c $GITHUB_ACTOR || true) |
| 38 | + COUNT_TOKEN=$(echo $POM | grep -c $GITHUB_TOKEN || true) |
| 39 | +
|
| 40 | + if [ $COUNT_REPOS -ne 2; then |
| 41 | + echo ::error:: could not find 2 repositories in the settings.xml |
| 42 | + fi |
| 43 | +
|
| 44 | + if [ $COUNT_NAME_MAVEN -ne 1 ]; then |
| 45 | + echo ::error:: could not find name maven-releases |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + if [ $COUNT_NAME_SNAP -ne 1; then |
| 50 | + echo ::error:: could not find name snapshots |
| 51 | + fi |
| 52 | +
|
| 53 | + if [ $COUNT_ACTOR -ne 2 ]; then |
| 54 | + echo ::error:: could not find username for each repository |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | +
|
| 58 | + if [ $COUNT_TOKEN -ne 2 ]; then |
| 59 | + echo ::error:: could not find token for each repository |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments