Skip to content

Commit b0b11af

Browse files
authored
Use devcontainers for CI workflows (#188)
* Use devcontainers for CI workflows This PR updates our GitHub Actions workflows to use devcontainers instead of directly setting up the environment on the runner. This approach: - Ensures CI runs in the same environment as development - Simplifies workflow configuration - Reduces maintenance by centralizing environment setup in the devcontainer - Increases CI timeout to accommodate container build time * use devcontainers for CI workflows * unify ci workflow * fix permissions
1 parent 1162cd7 commit b0b11af

File tree

1 file changed

+30
-65
lines changed

1 file changed

+30
-65
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,47 @@ name: CI
22

33
on:
44
pull_request:
5-
branches:
6-
- "*"
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
710
push:
8-
branches:
9-
- main
10-
- v1
11-
11+
branches: "main"
1212
jobs:
13-
scan:
14-
timeout-minutes: 10
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
21-
- name: Set up Ruby
22-
uses: ruby/setup-ruby@v1
23-
with:
24-
bundler-cache: true
25-
26-
lint:
27-
timeout-minutes: 10
13+
test:
14+
timeout-minutes: 15
2815
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
2920
steps:
3021
- name: Checkout code
3122
uses: actions/checkout@v4
3223

33-
- name: Set up Ruby
34-
uses: ruby/setup-ruby@v1
35-
with:
36-
bundler-cache: true
37-
38-
- name: Lint code for consistent style
39-
run: bundle exec standardrb
40-
41-
test:
42-
timeout-minutes: 10
43-
runs-on: ubuntu-latest
44-
steps:
45-
- uses: actions/checkout@v4
46-
47-
- name: Setup Ruby
48-
uses: ruby/setup-ruby@v1
24+
- name: Login to GitHub Container Registry
25+
uses: docker/login-action@v3
4926
with:
50-
bundler-cache: true
51-
52-
- name: Install pnpm
53-
uses: pnpm/action-setup@v4
54-
with:
55-
run_install: false
56-
57-
- name: Setup Node
58-
uses: actions/setup-node@v4
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build and run dev container task
32+
uses: devcontainers/[email protected]
5933
with:
60-
node-version-file: ".node-version"
61-
cache: 'pnpm'
62-
63-
- name: Install dependencies
64-
run: |
65-
sudo apt-get update
66-
sudo apt-get install -y -qq libvips
67-
pnpm install
68-
69-
- name: Run tests
70-
env:
71-
RAILS_ENV: test
72-
# RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
73-
run: |
74-
bin/rails test:prepare
75-
bin/rails db:test:prepare
76-
bin/rails test
34+
imageName: ghcr.io/ruby-ui/web-devcontainer
35+
cacheFrom: ghcr.io/ruby-ui/web-devcontainer
36+
push: always
37+
runCmd: |
38+
bundle exec standardrb
39+
bin/rails test:prepare
40+
bin/rails db:test:prepare
41+
bin/rails test
7742
7843
heroku-deploy:
7944
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/PhlexUI-web' }}
80-
needs: [lint, test]
45+
needs: [test]
8146
runs-on: ubuntu-latest
8247

8348
steps:
@@ -92,7 +57,7 @@ jobs:
9257

9358
fly-deploy:
9459
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
95-
needs: [lint, test]
60+
needs: [test]
9661
name: Deploy app
9762
runs-on: ubuntu-latest
9863
concurrency: deploy-group

0 commit comments

Comments
 (0)