|
| 1 | +name: "Release" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + name: Build container |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: "☁️ checkout repository" |
| 14 | + uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: "🔧 setup buildx" |
| 17 | + uses: docker/setup-buildx-action@v1 |
| 18 | + |
| 19 | + - name: "📦 docker build" |
| 20 | + uses: docker/build-push-action@v2 |
| 21 | + with: |
| 22 | + context: . |
| 23 | + tags: ${{ github.repository }}:latest |
| 24 | + outputs: type=docker,dest=/tmp/docker.tar |
| 25 | + push: false |
| 26 | + |
| 27 | + - name: "📂 docker artifacts" |
| 28 | + uses: actions/upload-artifact@v2 |
| 29 | + with: |
| 30 | + name: docker |
| 31 | + path: /tmp/docker.tar |
| 32 | + |
| 33 | + build: |
| 34 | + name: Build application |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: "☁️ checkout repository" |
| 38 | + uses: actions/checkout@v2 |
| 39 | + |
| 40 | + - name: "🔧 setup node" |
| 41 | + |
| 42 | + with: |
| 43 | + node-version: 16 |
| 44 | + |
| 45 | + - name: "🔧 setup cache" |
| 46 | + uses: actions/cache@v2 |
| 47 | + with: |
| 48 | + path: ~/.npm |
| 49 | + key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-node- |
| 52 | +
|
| 53 | + - name: "🔧 install npm@7" |
| 54 | + run: npm i -g npm@7 |
| 55 | + |
| 56 | + - name: "📦 install dependencies" |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: "🚀 static app" |
| 60 | + run: npm run build |
| 61 | + |
| 62 | + - name: "📂 production artifacts" |
| 63 | + uses: actions/upload-artifact@v2 |
| 64 | + with: |
| 65 | + name: build |
| 66 | + path: build |
| 67 | + |
| 68 | + release: |
| 69 | + environment: |
| 70 | + name: production |
| 71 | + url: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.release.outputs.version }} |
| 72 | + name: Semantic release |
| 73 | + needs: |
| 74 | + - docker |
| 75 | + - build |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - name: "☁️ checkout repository" |
| 79 | + uses: actions/checkout@v2 |
| 80 | + with: |
| 81 | + fetch-depth: 0 |
| 82 | + |
| 83 | + - name: "🔧 setup node" |
| 84 | + |
| 85 | + with: |
| 86 | + node-version: 16 |
| 87 | + |
| 88 | + - name: "🔧 setup cache" |
| 89 | + uses: actions/cache@v2 |
| 90 | + with: |
| 91 | + path: ~/.npm |
| 92 | + key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} |
| 93 | + restore-keys: | |
| 94 | + ${{ runner.os }}-node- |
| 95 | +
|
| 96 | + - name: "🔧 install npm@7" |
| 97 | + run: npm i -g npm@7 |
| 98 | + |
| 99 | + - name: "📦 install dependencies" |
| 100 | + run: npm ci |
| 101 | + |
| 102 | + - name: "📂 download docker artifacts" |
| 103 | + uses: actions/download-artifact@v2 |
| 104 | + with: |
| 105 | + name: docker |
| 106 | + path: /tmp |
| 107 | + |
| 108 | + - name: "📦 load tag" |
| 109 | + run: | |
| 110 | + docker load --input /tmp/docker.tar |
| 111 | + docker image ls -a |
| 112 | +
|
| 113 | + - name: "📂 download build artifacts" |
| 114 | + uses: actions/download-artifact@v2 |
| 115 | + with: |
| 116 | + name: build |
| 117 | + path: /tmp/build |
| 118 | + |
| 119 | + - name: "🚀 release" |
| 120 | + id: release |
| 121 | + env: |
| 122 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 123 | + REPO_OWNER: ${{ github.repository_owner }} |
| 124 | + GIT_AUTHOR_NAME: ${{ github.event.commits[0].author.username }} |
| 125 | + GIT_AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }} |
| 126 | + GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} |
| 127 | + GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} |
| 128 | + run: | |
| 129 | + cp -R /tmp/build ./build |
| 130 | + npx semantic-release |
| 131 | + echo "::set-output name=version::$(cat package.json | jq -r '.version')" |
| 132 | +
|
| 133 | + deploy: |
| 134 | + name: Deploy to static |
| 135 | + needs: |
| 136 | + - build |
| 137 | + - release |
| 138 | + runs-on: ubuntu-latest |
| 139 | + steps: |
| 140 | + - name: "☁️ checkout repository" |
| 141 | + uses: actions/checkout@v2 |
| 142 | + |
| 143 | + - name: "📂 download artifacts" |
| 144 | + uses: actions/download-artifact@v2 |
| 145 | + with: |
| 146 | + name: build |
| 147 | + path: /home/runner/build |
| 148 | + |
| 149 | + - name: "📂 copy artifacts" |
| 150 | + run: | |
| 151 | + cp -R /home/runner/build . |
| 152 | + ls -lahH ./build |
| 153 | +
|
| 154 | + - name: "🚀 deploy static" |
| 155 | + uses: peaceiris/actions-gh-pages@v3 |
| 156 | + with: |
| 157 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 158 | + publish_dir: ./build |
| 159 | + commit_message: ${{ github.event.head_commit.message }} |
| 160 | + enable_jekyll: false |
| 161 | + cname: docs.opensauced.pizza |
| 162 | + |
| 163 | + cleanup: |
| 164 | + name: Cleanup actions |
| 165 | + needs: |
| 166 | + - deploy |
| 167 | + runs-on: ubuntu-latest |
| 168 | + steps: |
| 169 | + - name: "♻️ remove build artifacts" |
| 170 | + uses: geekyeggo/delete-artifact@v1 |
| 171 | + with: |
| 172 | + name: | |
| 173 | + build |
| 174 | + docker |
0 commit comments