Update versions of github actions (+ test fix) #4
Workflow file for this run
This file contains 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
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'smart-guessr/v*' | |
paths: | |
- smart-guessr/** | |
- .github/workflows/smart-guessr.yml | |
pull_request: | |
paths: | |
- smart-guessr/** | |
- .github/workflows/smart-guessr.yml | |
name: Test and docker (smart-guessr) | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: blockscout/smart-guessr | |
defaults: | |
run: | |
working-directory: smart-guessr | |
jobs: | |
test: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install | |
- name: Run tests | |
run: bun test | |
if: success() || failure() | |
push: | |
name: Docker build and docker push | |
needs: | |
- test | |
if: | | |
always() && | |
(needs.test.result == 'success' || needs.test.result == 'cancelled') | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions-ecosystem/action-regex-match@v2 | |
id: regex | |
with: | |
text: ${{ github.ref }} | |
regex: '^(refs\/tags\/smart-guessr\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$' | |
- name: Extract tag name | |
id: tags_extractor | |
run: | | |
t=${{ steps.regex.outputs.group2 }} | |
m=${{ steps.regex.outputs.group4 }} | |
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: "smart-guessr" | |
file: "smart-guessr/Dockerfile" | |
push: ${{ steps.tags_extractor.outputs.tags != '' }} | |
tags: ${{ steps.tags_extractor.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache | |
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }} |