Merge pull request #107 from ruby-no-kai/title #83
This file contains hidden or 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: ci | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - test | |
| jobs: | |
| test: | |
| uses: ./.github/workflows/_test.yml | |
| build: | |
| name: build | |
| permissions: | |
| contents: read | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image-tag: "${{ steps.login-ecr.outputs.registry }}/sponsor-app:${{ github.sha }}" | |
| steps: | |
| - uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0 | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| #- uses: ruby/setup-ruby@v1 | |
| # with: | |
| # ruby-version: '3.1' | |
| # bundler-cache: true | |
| - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | |
| with: | |
| aws-region: "us-west-2" | |
| role-skip-session-tagging: true | |
| role-to-assume: "arn:aws:iam::005216166247:role/GhaDockerPush" | |
| mask-aws-account-id: false | |
| - id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 | |
| - run: "echo '${{ github.sha }}' > REVISION" | |
| - name: 'Build Docker image' | |
| uses: 'docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6' # v3.3.1 | |
| with: | |
| context: '.' | |
| push: true | |
| tags: "${{ steps.login-ecr.outputs.registry }}/sponsor-app:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/sponsor-app:latest" | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # prevent manifest from being pushed instead of image on the specified tags for Lambda | |
| provenance: false | |
| sbom: false | |
| deploy-prod: | |
| if: "${{ success() && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}" | |
| name: deploy-prod | |
| needs: ["build", "test"] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| runs-on: ubuntu-slim | |
| concurrency: | |
| group: production | |
| cancel-in-progress: true | |
| environment: | |
| name: production | |
| url: https://sponsorships.rubykaigi.org | |
| env: | |
| BUNDLE_GEMFILE: "${{ github.workspace }}/deploy/Gemfile" | |
| IMAGE_URI: "${{ needs.build.outputs.image-tag }}" | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0 | |
| with: | |
| ruby-version: '3.4' | |
| bundler-cache: true | |
| - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | |
| with: | |
| aws-region: "us-west-2" | |
| role-skip-session-tagging: true | |
| role-to-assume: "arn:aws:iam::005216166247:role/GhaSponsorDeploy" | |
| mask-aws-account-id: false | |
| - run: 'aws lambda update-function-code --function-name sponsor-app-runner-prd --image-uri "$IMAGE_URI" && aws lambda wait function-updated --function-name sponsor-app-runner-prd' | |
| - run: 'bundle exec ./deploy/lambrunner.rb sponsor-app-runner-prd bundle exec rake db:migrate' | |
| - run: 'aws lambda update-function-code --function-name sponsor-app-lambdakiq-prd --image-uri "$IMAGE_URI" && aws lambda wait function-updated --function-name sponsor-app-lambdakiq-prd' | |
| - run: 'aws lambda update-function-code --function-name sponsor-app-web-prd --image-uri "$IMAGE_URI" && aws lambda wait function-updated --function-name sponsor-app-web-prd' |