sbow latest commit #9
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: Create and deploy application | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| build-and-push_image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: kostecki/wheel-of-styles | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Get the latest commit hash and message | |
| id: git_info | |
| run: | | |
| LATEST_COMMIT_HASH=$(git log -1 --pretty=format:"%h") | |
| LATEST_COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
| echo "LATEST_COMMIT_HASH=\"$LATEST_COMMIT_HASH\"" >> $GITHUB_ENV | |
| echo "LATEST_COMMIT_MESSAGE=\"$LATEST_COMMIT_MESSAGE\"" >> $GITHUB_ENV | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 23.6.0 | |
| - name: Use pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.15.4 | |
| - name: Make envfile | |
| uses: SpicyPizza/create-envfile@v2 | |
| with: | |
| # Commit Info | |
| envkey_LATEST_COMMIT_HASH: ${{ env.LATEST_COMMIT_HASH }} | |
| envkey_LATEST_COMMIT_MESSAGE: ${{ env.LATEST_COMMIT_MESSAGE }} | |
| # App | |
| envkey_SESSION_SECRET: ${{ secrets.SESSION_SECRET }} | |
| envkey_ADMIN_USER_ID: ${{ vars.ADMIN_USER_ID }} | |
| # Untappd | |
| envkey_UNTAPPD_API_URL: ${{ vars. UNTAPPD_API_URL }} | |
| envkey_UNTAPPD_DEVICE_UDID: ${{ vars.UNTAPPD_DEVICE_UDID }} | |
| envkey_UNTAPPD_CLIENT_ID: ${{ vars.UNTAPPD_CLIENT_ID }} | |
| envkey_UNTAPPD_CLIENT_SECRET: ${{ secrets.UNTAPPD_CLIENT_SECRET }} | |
| - name: Set pnpm store path | |
| run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV | |
| - name: Cache pnpm modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.PNPM_STORE_PATH }} | |
| key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| pnpm-${{ runner.os }}- | |
| - name: Install node modules | |
| run: pnpm install | |
| - name: Build the application | |
| run: pnpm run build | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: image=moby/buildkit:latest | |
| - name: Extract metadata (tags and labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Login to the container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ steps.meta.outputs.tags }} | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Ping Portainer | |
| uses: fjogeleit/http-request-action@v1 | |
| with: | |
| url: ${{ secrets.PORTAINER_URL }} | |
| method: POST | |
| timeout: 15000 | |
| retry: 3 |