|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags: |
| 9 | + # pre-release tag |
| 10 | + - "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+" |
| 11 | + # release tags |
| 12 | + - "202[3-9].[0-9][0-9].[0-9]+" |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +jobs: |
| 19 | + tests-ui: |
| 20 | + uses: ./.github/workflows/tests-ui.yml |
| 21 | + if: github.ref_type == 'tag' |
| 22 | + |
| 23 | + tests-pytest: |
| 24 | + uses: ./.github/workflows/tests-pytest.yml |
| 25 | + if: github.ref_type == 'tag' |
| 26 | + |
| 27 | + deploy: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + needs: [tests-ui, tests-pytest] |
| 30 | + if: (!cancelled()) |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version-file: .github/workflows/.python-version |
| 39 | + cache: pip |
| 40 | + cache-dependency-path: "**/pyproject.toml" |
| 41 | + |
| 42 | + - name: Write python packages to file |
| 43 | + run: | |
| 44 | + python -m venv .venv |
| 45 | + source .venv/bin/activate |
| 46 | + pip install pipdeptree |
| 47 | + pip install -e . |
| 48 | + pipdeptree |
| 49 | + pipdeptree >> pems/static/requirements.txt |
| 50 | +
|
| 51 | + - name: Write commit SHA to file |
| 52 | + run: echo "${{ github.sha }}" >> pems/static/sha.txt |
| 53 | + |
| 54 | + - name: Docker Login to GitHub Container Registry |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Set up QEMU |
| 62 | + uses: docker/setup-qemu-action@v3 |
| 63 | + |
| 64 | + - name: Set up Docker Buildx |
| 65 | + id: buildx |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Build, tag, and push image to GitHub Container Registry |
| 69 | + uses: docker/build-push-action@v6 |
| 70 | + with: |
| 71 | + platforms: linux/amd64,linux/arm64 |
| 72 | + builder: ${{ steps.buildx.outputs.name }} |
| 73 | + build-args: GIT-SHA=${{ github.sha }} |
| 74 | + cache-from: type=gha,scope=compilerla |
| 75 | + cache-to: type=gha,scope=compilerla,mode=max |
| 76 | + context: . |
| 77 | + file: appcontainer/Dockerfile |
| 78 | + push: true |
| 79 | + tags: ghcr.io/${{ github.repository }}:${{ github.sha }} |
| 80 | + |
| 81 | + release: |
| 82 | + needs: deploy |
| 83 | + if: ${{ github.ref_type == 'tag' && !contains(github.ref, '-rc') }} |
| 84 | + runs-on: ubuntu-latest |
| 85 | + permissions: |
| 86 | + # https://github.com/softprops/action-gh-release#permissions |
| 87 | + contents: write |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@v4 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + |
| 95 | + - name: Release |
| 96 | + uses: softprops/action-gh-release@v2 |
| 97 | + with: |
| 98 | + prerelease: false |
| 99 | + generate_release_notes: true |
0 commit comments