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
name: Docker Image CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
RAILS_ENV: test | |
TEST_IMAGE_TAG: wave:test | |
TEMP_IMAGE_NAME: image_ | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-multi-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-multi-buildx | |
- name: Build image | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
context: . | |
target: build | |
tags: ${{ env.TEST_IMAGE_TAG }} | |
outputs: type=docker,dest=/tmp/${{ env.TEMP_IMAGE_NAME }}.tar | |
- name: Run Tests | |
run: docker compose run --rm web bin/rspec | |
- name: Push Docker Image (if on main) | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
target: deployment | |
tags: ${{ env.TEST_IMAGE_TAG }} | |
#repository: your-docker-hub-username/your-repository-name | |
deploy: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
environment: production | |
steps: | |
- name: Deploy to Production | |
run: | | |
# ... your deployment commands ... |