publish #17
This file contains hidden or 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
| #----------------------------------------------------------------------------------------- | |
| # | |
| # Публикация bugget-api и bugget-ui | |
| # | |
| #----------------------------------------------------------------------------------------- | |
| name: publish | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| workflow_dispatch: | |
| inputs: | |
| component: | |
| description: "Выберите, что деплоить" | |
| required: true | |
| default: "backend" | |
| type: choice | |
| options: | |
| - backend | |
| - frontend | |
| version: | |
| description: "Версия (например, v1.2.3)" | |
| required: true | |
| jobs: | |
| backend: | |
| if: github.event.inputs.component == 'backend' || startsWith(github.ref, 'refs/tags/backend-') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_LOGIN }} | |
| password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
| - name: Set version | |
| run: | | |
| if [ -z "${{ github.event.inputs.version }}" ]; then | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build and push Backend Multi-Arch | |
| run: | | |
| cd backend | |
| docker buildx create --use | |
| docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_LOGIN }}/bugget-api:${{ env.VERSION }} --push -f ./Bugget/Dockerfile . | |
| docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_LOGIN }}/bugget-api:latest --push -f ./Bugget/Dockerfile . | |
| frontend: | |
| if: github.event.inputs.component == 'frontend' || startsWith(github.ref, 'refs/tags/frontend-') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_LOGIN }} | |
| password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
| - name: Set version | |
| run: | | |
| if [ -z "${{ github.event.inputs.version }}" ]; then | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build and push Frontend Multi-Arch | |
| run: | | |
| cd frontend | |
| docker buildx create --use | |
| docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_LOGIN }}/bugget-ui:${{ env.VERSION }} --push . | |
| docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_LOGIN }}/bugget-ui:latest --push . |