|
| 1 | +name: Build & Deploy to Minio |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-minio: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - name: Use Node.js 18.x |
| 15 | + uses: actions/setup-node@v4 |
| 16 | + with: |
| 17 | + node-version: 18.x |
| 18 | + - run: yarn |
| 19 | + - run: yarn build |
| 20 | + - name: Create tar from built plugin |
| 21 | + run: | |
| 22 | + BUILDFOLDER="dist" |
| 23 | + MANIFEST=$(find ./$BUILDFOLDER -name plugin-manifest.json) |
| 24 | + [ -z $MANIFEST ] && cp plugin-manifest $BUILDFOLDER |
| 25 | + MANIFEST="$BUILDFOLDER/plugin-manifest.json" |
| 26 | + VERSION=$(jq '.version' $MANIFEST -r) |
| 27 | + URL=$(jq '.url' $MANIFEST -r) |
| 28 | + echo "version=$VERSION" |
| 29 | + mkdir -p output |
| 30 | + tar -C $BUILDFOLDER -czf output/$VERSION.tar.gz . |
| 31 | + ls -la output |
| 32 | + echo "version=$VERSION" >> $GITHUB_ENV |
| 33 | + REPO_NAME="$(basename $GITHUB_REPOSITORY)" |
| 34 | + echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV |
| 35 | + ENTRYPOINT_NAME=$(basename $URL) |
| 36 | + ENTRYPOINT_PATH=$(find ./$BUILDFOLDER -name $ENTRYPOINT_NAME | sed "s|^./$BUILDFOLDER/||") |
| 37 | + UPLOAD_URL="$MINIO_URL/flotiq-plugins-dev/$REPO_NAME/$GITHUB_HEAD_REF/$ENTRYPOINT_PATH" |
| 38 | + echo $UPLOAD_URL |
| 39 | + tmp=$(mktemp) |
| 40 | + jq --arg upload_url "$UPLOAD_URL" '.url = $upload_url' $MANIFEST > "$tmp" && mv "$tmp" $MANIFEST |
| 41 | + env: |
| 42 | + MINIO_URL: ${{ secrets.MINIO_ENDPOINT }} |
| 43 | + - name: Minio Deploy |
| 44 | + uses: lovellfelix/minio-deploy-action@v1 |
| 45 | + with: |
| 46 | + endpoint: ${{ secrets.MINIO_ENDPOINT }} |
| 47 | + access_key: ${{ secrets.MINIO_ACCESS_KEY }} |
| 48 | + secret_key: ${{ secrets.MINIO_SECRET_KEY }} |
| 49 | + bucket: 'flotiq-plugins-dev' |
| 50 | + # Optional inputs with their defaults: |
| 51 | + source_dir: 'dist' |
| 52 | + target_dir: '/${{ env.REPO_NAME }}/${{ github.head_ref }}/' |
| 53 | + - name: Create artifact |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: plugin-package |
| 57 | + path: output/${{ env.version }}.tar.gz |
| 58 | + dependabot: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: github.actor == 'dependabot[bot]' |
| 61 | + steps: |
| 62 | + - name: Dependabot metadata |
| 63 | + id: metadata |
| 64 | + uses: dependabot/fetch-metadata@v1 |
| 65 | + with: |
| 66 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 67 | + - name: Approve a PR |
| 68 | + run: gh pr review --approve "$PR_URL" |
| 69 | + env: |
| 70 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 71 | + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
0 commit comments