Merge pull request #43 from vfarid/42-عدم-غیر-فعال-سازی-فرگمنت #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build worker.js | |
on: | |
push: | |
branches: ["main"] | |
release: | |
types: ["published"] | |
jobs: | |
build: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "latest" | |
cache: "npm" | |
- name: Install modules | |
run: npm i wrangler | |
- name: Build | |
run: npx wrangler build | |
- name: Add Header | |
run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\n * v2ray Subscription Worker (${{ github.sha }})\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat ${{ github.workspace }}/dist/worker.js)" > ${{ github.workspace }}/dist/worker.js | |
- name: Upload to Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: worker | |
path: ${{ github.workspace }}/dist/worker.js | |
- name: Add Release Header | |
run: echo -e "/*!\n * v2ray Subscription Worker ${{ github.event.release.tag_name }}\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat ${{ github.workspace }}/dist/worker-original.js)" > ${{ github.workspace }}/dist/worker.js | |
- name: Upload to GitHub Release | |
uses: svenstaro/upload-release-action@v2 | |
if: github.event_name == 'release' | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ github.workspace }}/dist/worker.js | |
asset_name: worker.js | |
tag: ${{ github.ref }} | |
overwrite: true |