|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + branches: [main] |
| 7 | + types: |
| 8 | + - completed |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 14 | + outputs: |
| 15 | + new_release_published: ${{ steps.semantic.outputs.new_release_published }} |
| 16 | + new_release_version: ${{ steps.semantic.outputs.new_release_version }} |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v1 |
| 20 | + - name: Cache npm dependencies |
| 21 | + uses: actions/cache@v2 |
| 22 | + with: |
| 23 | + path: '~/.npm' |
| 24 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 25 | + restore-keys: | |
| 26 | + ${{ runner.os }}-node- |
| 27 | + - name: npm install |
| 28 | + run: npm ci |
| 29 | + - name: Release |
| 30 | + uses: cycjimmy/semantic-release-action@v2 |
| 31 | + id: semantic |
| 32 | + with: |
| 33 | + semantic_version: 17 |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + push_to_registry: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: [release] |
| 39 | + if: needs.release.outputs.new_release_published == 'true' |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v2 |
| 43 | + - name: Set up QEMU |
| 44 | + uses: docker/setup-qemu-action@v1 |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v1 |
| 47 | + - name: Cache Docker layers |
| 48 | + uses: actions/cache@v2 |
| 49 | + with: |
| 50 | + path: /tmp/.buildx-cache |
| 51 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 52 | + restore-keys: | |
| 53 | + ${{ runner.os }}-buildx- |
| 54 | + - name: Login to GitHub Container Registry |
| 55 | + uses: docker/login-action@v1 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.repository_owner }} |
| 59 | + password: ${{ secrets.CR_PAT }} |
| 60 | + - name: Build and push |
| 61 | + uses: docker/build-push-action@v2 |
| 62 | + with: |
| 63 | + context: . |
| 64 | + file: ./Dockerfile |
| 65 | + push: true |
| 66 | + tags: | |
| 67 | + ghcr.io/nicklason/tf2-schema-worker:latest |
| 68 | + ghcr.io/nicklason/tf2-schema-worker:${{ needs.release.outputs.new_release_version }} |
| 69 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 70 | + cache-to: type=local,dest=/tmp/.buildx-cache |
0 commit comments