Skip to content

Bump actions/upload-artifact from 3 to 4 #994

Bump actions/upload-artifact from 3 to 4

Bump actions/upload-artifact from 3 to 4 #994

Workflow file for this run

# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
# NOTE: https://github.saobby.my.eu.orgmunity/t/retry-for-failed-steps/17136/7
name: "Ruby on Rails CI"
on:
push:
branches: [develop]
pull_request:
branches: [develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- name: Setup Ruby 3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Build and run test
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_TEST_KEY }}
run: |
bin/setup
# test prepare required for tailwind css file required in application erb
bin/rails test:prepare --trace
bin/rails test
- name: system-tests
id: system-test
continue-on-error: true # make the step always success and set status later
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_TEST_KEY }}
run: |
bin/rails test:system --trace HEADLESS=true CUPRITE=true CUPRITE_JS_ERRORS=true APP_HOST='127.0.0.1'
- name: system-test-retry
id: system-test-retry-1
continue-on-error: true # make the step always success and set status later
if: steps.system-test.outcome=='failure' # check the step outcome, retry 1st time
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_TEST_KEY }}
run: |
bin/rails test:system --trace HEADLESS=true CUPRITE=true CUPRITE_JS_ERRORS=true APP_HOST='127.0.0.1'
- name: Upload failed system test images
uses: actions/upload-artifact@v4
if: steps.system-test.outcome=='failure' || steps.system-test-retry-1.outcome=='failure' # check the step outcome, retry 1st time
with:
path: ./tmp/capybara/screenshots/failures_*.png
- name: set the status # set the workflow status if command failed
if: steps.system-test.outcome=='failure'
run: |
if ${{ steps.system-test-retry-1.outcome=='success' }}; then
echo 'the first system test failed, but the second one passed'
else
echo 'the first system test failed, and the second one also failed'
exit 1
fi
auto-merge:
name: Auto-Merge PRs by Dependabot
needs: test
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: fastify/github-action-merge-dependabot@v3.9.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
target: minor
deploy:
needs: test
if: ${{ github.ref == 'refs/heads/develop' }}
runs-on: ubuntu-latest
environment: staging
steps:
- name: checkout code
uses: actions/checkout@v3
- name: Setup Ruby 3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: deploy to heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }}
run: |
gem install dpl && gem install faraday -v '~> 1.8.0'
dpl --provider=heroku --api-key=${HEROKU_API_KEY} --app=${HEROKU_APP_NAME}