build: use older version of an action #423
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
name: Process v3 push or PR | |
on: | |
push: | |
branches: | |
- v3 | |
pull_request: | |
branches: | |
- v3 | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: "Set time zone to Europe/Helsinki" | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: "Europe/Helsinki" | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: yarn | |
- name: Install dependencies and build shared components | |
run: yarn setup | |
- name: Run linters | |
run: yarn lint | |
# - name: lint SVG sprites using xmllint | |
# run: | | |
# sudo apt install -y libxml2-utils | |
# xmllint --nonet --noout static/assets/svg-sprite.*.svg | |
unit-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: "Set time zone to Europe/Helsinki" | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: "Europe/Helsinki" | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: yarn | |
- name: Install dependencies and build shared components | |
run: yarn setup | |
- name: build relay queries | |
run: yarn relay | |
- name: Run unit tests | |
run: yarn run test-coverage | |
- name: Send test coverage report | |
run: yarn run test-report | |
docker-push-v3: | |
if: github.ref == 'refs/heads/v3' | |
needs: | |
- lint | |
- unit-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set time zone to Europe/Helsinki | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: "Europe/Helsinki" | |
- name: Create buildInfo.js file content | |
id: build-info | |
run: echo "::set-output name=content::export const COMMIT_ID = \"${GITHUB_SHA}\";\nexport const BUILD_TIME = \"$(date -Iminutes -u)\";" | |
- name: Create buildInfo.js file | |
uses: finnp/[email protected] | |
env: | |
FILE_NAME: "app/buildInfo.js" | |
FILE_DATA: ${{ steps.build-info.outputs.content }} | |
- name: Configure Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_AUTH }} | |
- name: Cache .yarn/cache | |
uses: actions/cache@v3 | |
with: | |
path: '.yarn/cache' | |
key: yarn-cache-${{ github.ref_name }} | |
restore-keys: yarn-cache-v2 | |
- name: Create Docker image tag | |
id: docker-tags | |
run: | | |
echo "::set-output name=permanent-tag::v3-$(date +"%Y-%m-%dT%H.%M.%S")-${GITHUB_SHA:0:7}" | |
- name: build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: | | |
hsldevcom/digitransit-ui:v3 | |
hsldevcom/digitransit-ui:${{ steps.docker-tags.outputs.permanent-tag }} | |
# https://github.com/docker/build-push-action/blob/9472e9021074a3cb3279ba431598b8836d40433f/docs/advanced/cache.md#github-cache | |
# https://github.com/moby/buildkit#registry-push-image-and-cache-separately | |
cache-from: type=gha | |
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd | |
push: true |