From 86315aada4c972917803657c67dff196e5a52aaa Mon Sep 17 00:00:00 2001 From: Valerian Saliou Date: Wed, 28 Aug 2024 19:21:25 +0200 Subject: [PATCH] Revert "chore: temporarily produce a docker image on tag 0.5.3" This reverts commit 07821fde82e1f03d713d6fdd02d7047496474a89. --- .github/workflows/build.yml | 97 ++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a749c5b..b0ed26f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,72 @@ -on: [push] +on: + push: + tags: + - "*.*.*" name: Build and Release jobs: + build: + runs-on: ubuntu-latest + + outputs: + tag: ${{ steps.current_tag.outputs.tag }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install NodeJS + uses: actions/setup-node@v4 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org + + - name: Verify versions + run: node --version && npm --version && node -p process.versions.v8 + + - name: Cache build context + id: cache-node + uses: actions/cache@v3 + with: + path: | + ~/.npm + node_modules + key: ${{ runner.os }}-${{ runner.arch }}-node + + - name: Get current tag + id: current_tag + uses: WyriHaximus/github-action-get-previous-tag@v1 + with: + fallback: 0.0.0 + + - name: Install dependencies + run: npm install --no-audit + + - name: Run build + run: npm run build + + - name: Archive output files + run: tar -zcvf ./release-${{ steps.current_tag.outputs.tag }}.tar.gz dist/ + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.current_tag.outputs.tag }} Release + path: ./release-${{ steps.current_tag.outputs.tag }}.tar.gz + retention-days: 30 + + - name: Release new version + uses: softprops/action-gh-release@v1 + with: + name: ${{ steps.current_tag.outputs.tag }} + body: "⚠️ Changelog not yet provided." + files: ./release-${{ steps.current_tag.outputs.tag }}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ship: + needs: build environment: build-ship runs-on: ubuntu-latest @@ -27,7 +90,7 @@ jobs: ghcr.io/${{ github.repository }} tags: | type=ref,event=tag - type=raw,value=0.5.3 + type=raw,value=${{ needs.build.outputs.tag }} type=raw,value=latest - name: Login to Docker Hub @@ -44,14 +107,12 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Download build artifacts - uses: dawidd6/action-download-artifact@v6 + uses: actions/download-artifact@v4 with: - name: 0.5.3 Release - workflow: build.yml - search_artifacts: true + name: ${{ needs.build.outputs.tag }} Release - name: Extract build artifacts - run: tar -xzvf ./release-0.5.3.tar.gz + run: tar -xzvf ./release-${{ needs.build.outputs.tag }}.tar.gz - name: Build and push Docker image uses: docker/build-push-action@v6 @@ -60,3 +121,25 @@ jobs: tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} push: true + + deploy: + needs: build + environment: app.prose.org + runs-on: ubuntu-latest + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.tag }} Release + + - name: Extract build artifacts + run: tar -xzvf ./release-${{ needs.build.outputs.tag }}.tar.gz + + - name: Deploy application + env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} + AWS_EC2_METADATA_DISABLED: true + run: | + aws s3 sync --delete --endpoint-url ${{ vars.S3_ENDPOINT }} dist/ s3://${{ vars.S3_BUCKET }}/${{ vars.S3_SITE_DOMAIN }}/