|
| 1 | +name: Build, push and deploy Fpsak-frontend |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | +env: |
| 8 | + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} |
| 9 | + CLUSTER: dev-fss |
| 10 | + NAMESPACE: t4 |
| 11 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 12 | + IMAGE_BASE: docker.pkg.github.com/${{ github.repository }}/fpsak-frontend |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + |
| 19 | + - name: Sjekk ut kode |
| 20 | + uses: actions/checkout@v2 |
| 21 | + - run: git fetch --prune --unshallow |
| 22 | + |
| 23 | + - name: Hent tag |
| 24 | + run: echo "::set-env name=TAG::$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)" |
| 25 | + |
| 26 | + - name: Sette opp Node |
| 27 | + uses: actions/setup-node@v1 |
| 28 | + with: |
| 29 | + node-version: 12.x |
| 30 | + |
| 31 | + - name: Run yarn install |
| 32 | + run: yarn install --ignore-optional --no-progress --frozen-lockfile |
| 33 | + |
| 34 | + - name: Run linting and tests |
| 35 | + run: yarn less:lint |
| 36 | + |
| 37 | + - name: Build |
| 38 | + run: | |
| 39 | + echo "::set-env name=IMAGE::$IMAGE_BASE:$TAG" |
| 40 | + yarn build |
| 41 | +
|
| 42 | + - name: Bygg, tag og push Docker image |
| 43 | + run: | |
| 44 | + docker -v |
| 45 | + docker build . --pull -t $IMAGE |
| 46 | + echo $GITHUB_TOKEN | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} --password-stdin |
| 47 | + docker push $IMAGE_BASE |
| 48 | +
|
| 49 | + - name: Opprett deployment issue |
| 50 | + if: success() |
| 51 | + uses: maxkomarychev/[email protected] |
| 52 | + id: createdeployissue |
| 53 | + with: |
| 54 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + title: Bygg av ${{ env.TAG }} |
| 56 | + body: | |
| 57 | + Kommenter med <b>/promote ${{ env.TAG }} cluster namespace</b>, hvor <b>cluster</b> er et gyldig clusternavn og <b>namespace</b> et eksisterende namespace i det clusteret. |
| 58 | + <table> |
| 59 | + <tr><th>Cluster</th><th>Namespace</th></tr> |
| 60 | + <tr><td>dev-fss</td><td>t4,q1</td></tr> |
| 61 | + <tr><td>prod-fss</td><td>default</td></tr> |
| 62 | + </table> |
| 63 | + - name: Trigg deploy til dev-fss t4 |
| 64 | + if: success() |
| 65 | + |
| 66 | + with: |
| 67 | + github-token: ${{secrets.NOTIFICATION}} |
| 68 | + script: | |
| 69 | + const issue = { owner: context.issue.owner, |
| 70 | + repo: context.issue.repo, |
| 71 | + issue_number: ${{ steps.createdeployissue.outputs.number }} } |
| 72 | + github.issues.createComment({...issue, |
| 73 | + title: 'Deploy av ${{ env.TAG }}', |
| 74 | + body: '/promote ${{ env.TAG }} ${{ env.CLUSTER }} ${{ env.NAMESPACE }}'}) |
0 commit comments