Skip to content

Commit

Permalink
update ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
8398a7 committed Oct 23, 2024
1 parent 649ab5b commit 2492475
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 76 deletions.
68 changes: 32 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
RAILS_ENV: test
TZ: /usr/share/zoneinfo/Asia/Tokyo
Expand All @@ -14,34 +14,24 @@ jobs:

services:
postgres:
image: postgres:11.5-alpine
image: postgres:17.0-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
redis:
image: redis:5.0.5-alpine
image: redis:7.4.1-alpine
ports:
- 6379:6379

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1
- name: yarn install
run: yarn install
node-version: 22
cache: yarn
- run: yarn install --frozen-lockfile
- name: Run Eslint and Prettier
run: yarn lint
- uses: ruby/setup-ruby@v1
Expand All @@ -64,33 +54,39 @@ jobs:
uses: paambaati/codeclimate-action@v3.0.0
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
NODE_OPTIONS: --openssl-legacy-provider
with:
coverageCommand: bundle exec rspec
- name: Archive artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ./tmp/test-results
build:
if: contains(github.ref, 'master')
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [test]
steps:
- uses: actions/checkout@v1
- name: docker login
run: echo $REGISTRY_TOKEN | docker login docker.pkg.github.com -u 8398a7 --password-stdin
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
- run: make pull build
- name: initialize gcloud sdk
run: |
echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
gcloud --quiet config set project iidx-app
gcloud --quiet config set compute/zone us-west1-b
gcloud auth configure-docker --quiet --project iidx-app
env:
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }}
- run: make push
- name: Get short SHA
id: vars
run: echo "SHA_TAG=$(git describe --tags --abbrev=10)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: login ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: 8398a7
password: ${{ secrets.REGISTRY_TOKEN }}
- name: build image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/8398a7/iidx_score_table/app:${{ env.SHA_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: 8398a7/action-slack@v3
with:
fields: repo,job
Expand All @@ -101,7 +97,7 @@ jobs:
if: always()
deploy:
if: contains(github.ref, 'master')
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [build]
steps:
- uses: actions/checkout@v1
Expand Down
14 changes: 10 additions & 4 deletions build/base.Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LABEL maintainer '8398a7 <8398a7@gmail.com>'

ENV \
HOME=/app \
NODE_OPTIONS='--openssl-legacy-provider' \
DEBIAN_FRONTEND=noninteractive \
RAILS_ENV=production \
SECRET_KEY_BASE=wip
Expand All @@ -13,10 +14,10 @@ RUN \
apt-get update -qq && apt-get install -y \
git \
build-essential \
libpq-dev
RUN \
apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
libpq-dev \
tzdata \
curl && \
curl -sL https://deb.nodesource.com/setup_22.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update -qq && apt-get install -y --no-install-recommends nodejs yarn
Expand Down Expand Up @@ -47,3 +48,8 @@ COPY ./config $HOME/config
COPY config/database.k8s.yml $HOME/config/database.yml
ENV SENTRY_JS_DSN https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@sentry.io/y
RUN mkdir log && rails ts:routes assets:precompile

COPY . $HOME
RUN \
mv config/database.k8s.yml config/database.yml && \
mkdir -p tmp/pids
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
TAG := $(shell git describe --tags --abbrev=10)
BASE_IMAGE := docker.pkg.github.com/8398a7/abilitysheet/abilitysheet-base
IMAGE := gcr.io/iidx-app/abilitysheet
IMAGE := ghcr.io/8398a7/abilitysheet/app

.PHONY: pull
docker pull $(BASE_IMAGE):latest
.PHONY: build
build:
docker build --platform linux/amd64 --cache-from $(BASE_IMAGE):latest -t $(BASE_IMAGE):latest -f build/base.Dockerfile .
docker build --platform linux/amd64 -t $(IMAGE):$(TAG) -f build/Dockerfile .
docker build --platform linux/amd64 -t $(IMAGE):$(TAG) .
.PHONY: push
push:
docker push $(BASE_IMAGE):latest
docker push $(IMAGE):$(TAG)
29 changes: 0 additions & 29 deletions build/Dockerfile

This file was deleted.

0 comments on commit 2492475

Please sign in to comment.