|
1 | | -# Simple workflow for deploying static content to GitHub Pages |
2 | 1 | name: Deploy static content to Pages |
3 | 2 |
|
4 | 3 | on: |
5 | | - # Runs on pushes targeting the default branch |
6 | 4 | push: |
7 | | - branches: ["main"] |
8 | | - |
9 | | - # Allows you to run this workflow manually from the Actions tab |
| 5 | + tags: |
| 6 | + - '*' |
10 | 7 | workflow_dispatch: |
11 | 8 |
|
12 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
13 | 9 | permissions: |
14 | 10 | contents: read |
15 | 11 | pages: write |
16 | 12 | id-token: write |
17 | 13 |
|
18 | | -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
19 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
20 | 14 | concurrency: |
21 | 15 | group: "pages" |
22 | 16 | cancel-in-progress: false |
23 | 17 |
|
24 | 18 | jobs: |
25 | | - # Single deploy job since we're just deploying |
| 19 | + check-tags: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + tag: ${{ steps.version.outputs.tag }} |
| 23 | + release: ${{ steps.version.outputs.release }} |
| 24 | + steps: |
| 25 | + - name: Скачивание репозитория |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Определение версии |
| 29 | + id: version |
| 30 | + run: | |
| 31 | + tag=false |
| 32 | + release=false |
| 33 | + # Определяем, что было выбрано: branch или tag |
| 34 | + if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
| 35 | + TAG_NAME="${GITHUB_REF#refs/tags/}" |
| 36 | + echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT |
| 37 | + SEGMENTS=$(echo "$TAG_NAME" | tr '.' '\n' | wc -l) |
| 38 | + if [ "$SEGMENTS" -le 3 ]; then |
| 39 | + echo "release=true" >> $GITHUB_OUTPUT |
| 40 | + else |
| 41 | + echo "release=false" >> $GITHUB_OUTPUT |
| 42 | + fi |
| 43 | + else |
| 44 | + echo "tag=false" >> $GITHUB_OUTPUT |
| 45 | + echo "release=false" >> $GITHUB_OUTPUT |
| 46 | + fi |
| 47 | +
|
26 | 48 | deploy: |
| 49 | + needs: check-tags |
| 50 | + if: needs.check-tags.outputs.tag != 'false' |
27 | 51 | environment: |
28 | 52 | name: github-pages |
29 | 53 | url: ${{ steps.deployment.outputs.page_url }} |
|
36 | 60 | - name: Upload artifact |
37 | 61 | uses: actions/upload-pages-artifact@v3 |
38 | 62 | with: |
39 | | - # Upload entire repository |
40 | 63 | path: 'web' |
41 | 64 | - name: Deploy to GitHub Pages |
42 | 65 | id: deployment |
|
0 commit comments