|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +env: |
| 6 | + SERVICE_NAME: micro.starter |
| 7 | + SERVICE_NAME_CAPITALIZED: Micro.Starter |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v1 |
| 14 | + |
| 15 | + - name: Setup .NET Core |
| 16 | + uses: actions/setup-dotnet@v1 |
| 17 | + with: |
| 18 | + dotnet-version: 3.1.100 |
| 19 | + |
| 20 | + - name: Build |
| 21 | + run: dotnet build --configuration Release |
| 22 | + |
| 23 | + run-unit-tests: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v1 |
| 28 | + |
| 29 | + - name: Setup .NET Core |
| 30 | + uses: actions/setup-dotnet@v1 |
| 31 | + with: |
| 32 | + dotnet-version: 3.1.100 |
| 33 | + |
| 34 | + - name: Run Unit Tests |
| 35 | + run: dotnet test |
| 36 | + |
| 37 | + build-docker-image: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v1 |
| 42 | + |
| 43 | + - name: Build Docker Image |
| 44 | + run: | |
| 45 | + TAG=`git rev-parse --short=4 ${GITHUB_SHA}` |
| 46 | + echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login --username "${{ secrets.DOCKERHUB_LOGIN }}" --password-stdin |
| 47 | + docker build . -t fossapps/$SERVICE_NAME --build-arg VERSION=$TAG |
| 48 | + docker tag fossapps/$SERVICE_NAME fossapps/$SERVICE_NAME:$TAG |
| 49 | + docker push fossapps/$SERVICE_NAME:$TAG |
| 50 | + run-postman-tests: |
| 51 | + needs: build-docker-image |
| 52 | + runs-on: ubuntu-latest |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Pull Docker Image |
| 56 | + uses: actions/checkout@v1 |
| 57 | + with: |
| 58 | + name: docker-pull |
| 59 | + |
| 60 | + - name: 'Load Docker Image' |
| 61 | + run: | |
| 62 | + TAG=`git rev-parse --short=4 ${GITHUB_SHA}` |
| 63 | + docker pull fossapps/$SERVICE_NAME:$TAG |
| 64 | + - name: Spin-up Containers |
| 65 | + run: | |
| 66 | + TAG=`git rev-parse --short=4 ${GITHUB_SHA}` |
| 67 | + TAG=$TAG docker-compose -f ./docker-compose.ci.yml up -d |
| 68 | + - name: Run Postman Tests |
| 69 | + run: | |
| 70 | + cd ./${SERVICE_NAME_CAPITALIZED}.UnitTest/ExternalTests |
| 71 | + sh ./postman_tests.sh |
| 72 | +
|
| 73 | + publish: |
| 74 | + needs: [ build-docker-image, run-postman-tests ] |
| 75 | + runs-on: ubuntu-latest |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Checkout |
| 79 | + uses: actions/checkout@v1 |
| 80 | + - name: Semantic Release |
| 81 | + uses: cycjimmy/semantic-release-action@v2 |
| 82 | + env: |
| 83 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 84 | + DOCKERHUB_LOGIN: ${{secrets.DOCKERHUB_LOGIN}} |
| 85 | + DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} |
| 86 | + with: |
| 87 | + extra_plugins: | |
| 88 | + @semantic-release/[email protected] |
| 89 | + @semantic-release/[email protected] |
| 90 | + @semantic-release/[email protected] |
0 commit comments