fix: specs #1401
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: Continous Integration - CI | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: buildx | |
uses: docker/setup-buildx-action@master | |
- name: prepare artifacts | |
run: mkdir -p artifacts | |
- name: update version | |
run: | | |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then | |
echo "${GITHUB_REF_NAME}" > VERSION | |
else | |
ref=$(echo ${GITHUB_REF#refs/heads/}) | |
sha=$(echo ${GITHUB_SHA} | cut -c1-7) | |
echo "${ref} @${sha}" >> VERSION | |
fi | |
- name: docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: docker build test | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
push: false | |
target: test | |
tags: ghcr.io/${{ github.repository }}-test:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: docker build target | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
push: false | |
target: production | |
tags: ghcr.io/${{ github.repository }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# build-args: | |
# FOOTER_VERSION: "${{ github.ref_name }}" | |
- name: migrate | |
run: docker compose --file docker-compose.ci.yml run e2e_target bin/rails db:drop db:create db:migrate | |
- name: migrate | |
run: docker compose --file docker-compose.ci.yml up -d e2e_target | |
- name: bin/check | |
run: docker compose --file docker-compose.ci.yml run e2e_test bin/check | |
- if: github.event_name != 'pull_request' | |
name: docker tag | |
run: docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
- if: github.event_name != 'pull_request' | |
name: docker push | |
run: docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
- if: failure() | |
name: dump log | |
run: docker compose --file docker-compose.ci.yml logs > ./artifacts/docker-compose.ci.log | |
- if: failure() | |
name: dump tmp | |
run: docker cp $(docker compose --file docker-compose.ci.yml ps -qa e2e_test | head -n1):/rails/tmp ./artifacts/tmp | |
- if: failure() | |
name: upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: artifacts | |
path: artifacts |