publish-latest-mock-server #1636
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
| name: publish-latest-mock-server | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| inputs: | |
| simplelogin_version: | |
| description: 'SimpleLogin version to build (e.g., v4.74.7). Leave empty to use latest release.' | |
| required: false | |
| type: string | |
| env: | |
| FORCE_COLOR: 1 | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: kennethwussmann/simplelogin-client-mock-server | |
| concurrency: | |
| group: "mock-server" | |
| cancel-in-progress: true | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: read | |
| contents: read | |
| outputs: | |
| simplelogin_version: ${{ steps.version.outputs.simplelogin_version }} | |
| should_build: ${{ steps.check.outputs.should_build }} | |
| commit_sha: ${{ steps.vars.outputs.commit_sha }} | |
| steps: | |
| - name: Determine SimpleLogin version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.simplelogin_version }}" ]; then | |
| VERSION="${{ inputs.simplelogin_version }}" | |
| echo "Using manually specified version: ${VERSION}" | |
| else | |
| VERSION=$(curl -s https://api.github.com/repos/simple-login/app/releases/latest | jq -r .tag_name) | |
| echo "Using latest release version: ${VERSION}" | |
| fi | |
| echo "simplelogin_version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Set commit SHA | |
| id: vars | |
| run: echo "commit_sha=${{ github.sha }}" >> $GITHUB_OUTPUT | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if image exists | |
| id: check | |
| run: | | |
| if docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.simplelogin_version }} > /dev/null 2>&1; then | |
| echo "✓ Image for version ${{ steps.version.outputs.simplelogin_version }} already exists, skipping build" | |
| echo "should_build=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ Image for version ${{ steps.version.outputs.simplelogin_version }} does not exist, proceeding with build" | |
| echo "should_build=true" >> $GITHUB_OUTPUT | |
| fi | |
| build: | |
| needs: check-version | |
| if: needs.check-version.outputs.should_build == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ./.github/actions/pnpm-install | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build mock server | |
| env: | |
| SIMPLELOGIN_VERSION: ${{ needs.check-version.outputs.simplelogin_version }} | |
| run: pnpm tsx ./scripts/index.ts buildMockServer | |
| - name: Tag and push Docker image | |
| run: | | |
| docker tag simplelogin-mock:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.simplelogin_version }} | |
| docker tag simplelogin-mock:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.commit_sha }} | |
| docker tag simplelogin-mock:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.simplelogin_version }} | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.commit_sha }} | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| - name: Output image tags | |
| run: | | |
| echo "Published Docker images (AMD64):" | |
| echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" | |
| echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.simplelogin_version }}" | |
| echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.commit_sha }}" |