use a different hostname for testing purposes #23
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: CD | |
on: | |
push: | |
branches: | |
- master | |
env: | |
REGISTRY: ghcr.io | |
IMAGE: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
Deploy: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
runs-on: ubuntu-latest | |
# should mirror the ENV variables from ".env" file | |
env: | |
DOCKER_BUILDKIT: 1 | |
RAILS_ENV: production | |
RACK_ENV: production | |
LANG: en_US.UTF-8 | |
RAILS_SERVE_STATIC_FILES: true | |
RAILS_LOG_TO_STDOUT: true | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
DOCKER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} | |
DRAGONFLYAPP_URL: ${{ secrets.DRAGONFLYAPP_URL }} | |
DRAGONFLY_SECRET_KEY: ${{ secrets.DRAGONFLY_SECRET_KEY }} | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} | |
NEW_RELIC_LOG: stdout | |
SCOUT_APM_KEY: ${{ secrets.SCOUT_APM_KEY }} | |
S3_ASSET_HOST_URL: ${{ secrets.S3_ASSET_HOST_URL }} | |
S3_BUCKET: ${{ secrets.S3_BUCKET }} | |
S3_BUCKET_REGION: ${{ secrets.S3_BUCKET_REGION }} | |
S3_KEY_ID: ${{ secrets.S3_KEY_ID }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
SENDGRID_USERNAME: ${{ secrets.SENDGRID_USERNAME }} | |
SENDGRID_PASSWORD: ${{ secrets.SENDGRID_PASSWORD }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: set lower case owner name | |
run: | | |
echo "IMAGE_LC=${IMAGE,,}" >>${GITHUB_ENV} | |
env: | |
IMAGE: '${{ env.IMAGE }}' | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_LC }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set Tag | |
id: tag | |
run: | | |
echo "tag=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT | |
echo "🍿 service=${{ github.event.repository.name }}" | |
- name: Build image | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
context: . | |
builder: ${{ steps.buildx.outputs.name }} | |
build-args: | |
push: true | |
labels: | | |
"service=${{ github.event.repository.name }}" | |
tags: | | |
"ghcr.io/${{ env.IMAGE_LC }}:latest" | |
"ghcr.io/${{ env.IMAGE_LC }}:${{ steps.tag.outputs.tag }}" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.2.4 | |
bundler: none | |
- name: Install dependencies | |
run: | | |
gem install kamal -v 1.8.2 | |
- name: Run deploy command | |
run: | | |
git status --porcelain | |
kamal env push | |
kamal deploy --skip-push | |
- uses: actions/delete-package-versions@v4 | |
with: | |
owner: "${{ github.repository_owner }}" | |
package-name: "${{ github.event.repository.name }}" | |
package-type: 'container' | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
min-versions-to-keep: 3 |