1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ lint-and-test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Set up Ruby
18+ uses : ruby/setup-ruby@v1
19+ with :
20+ ruby-version : ' 3.3'
21+ bundler-cache : true
22+
23+ - name : Install dependencies
24+ run : bundle install
25+
26+ - name : Run linter (Standard Ruby)
27+ run : bundle exec rake standard
28+
29+ - name : Run tests
30+ run : bundle exec rake test
31+
32+ - name : Upload test results
33+ uses : actions/upload-artifact@v4
34+ if : always()
35+ with :
36+ name : test-results
37+ path : |
38+ coverage/
39+ tmp/
40+ retention-days : 7
41+
42+ validate-sam-template :
43+ runs-on : ubuntu-latest
44+ needs : lint-and-test
45+
46+ steps :
47+ - name : Checkout code
48+ uses : actions/checkout@v4
49+
50+ - name : Set up Ruby
51+ uses : ruby/setup-ruby@v1
52+ with :
53+ ruby-version : ' 3.3'
54+ bundler-cache : true
55+
56+ - name : Set up AWS SAM CLI
57+ uses : aws-actions/setup-sam@v2
58+
59+ - name : Validate SAM template
60+ run : sam validate --template template.yaml
61+
62+ - name : Build SAM application
63+ run : sam build --template template.yaml
64+
65+ - name : Upload SAM build artifacts
66+ uses : actions/upload-artifact@v4
67+ with :
68+ name : sam-build-artifacts
69+ path : .aws-sam/
70+ retention-days : 7
71+
72+ # Deploy job is temporarily disabled for initial testing
73+ # Will be enabled after manual deployment verification
74+ # deploy:
75+ # runs-on: ubuntu-latest
76+ # needs: [lint-and-test, validate-sam-template]
77+ # if: github.ref == 'refs/heads/main' && github.event_name == 'push'
78+ # environment: production
79+ # steps:
80+ # - name: Checkout code
81+ # uses: actions/checkout@v4
82+ # - name: Set up Ruby
83+ # uses: ruby/setup-ruby@v1
84+ # with:
85+ # ruby-version: '3.3'
86+ # bundler-cache: true
87+ # - name: Set up AWS SAM CLI
88+ # uses: aws-actions/setup-sam@v2
89+ # - name: Configure AWS credentials
90+ # uses: aws-actions/configure-aws-credentials@v4
91+ # with:
92+ # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
93+ # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
94+ # aws-region: ap-northeast-1
95+ # - name: Deploy to AWS
96+ # run: |
97+ # sam deploy \
98+ # --template-file .aws-sam/build/template.yaml \
99+ # --stack-name smalruby-infra-prod \
100+ # --parameter-overrides Stage=prod \
101+ # --capabilities CAPABILITY_IAM \
102+ # --no-confirm-changeset \
103+ # --no-fail-on-empty-changeset
0 commit comments