From d6d309c54298ba529370e435e393ef1a5a763af2 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Fri, 25 Feb 2022 12:13:46 +0000 Subject: [PATCH] Checkout latest release tag for production pipeline --- .github/workflows/production_pipeline.yml | 62 +++++++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/.github/workflows/production_pipeline.yml b/.github/workflows/production_pipeline.yml index 201fc4178..c55a11bca 100644 --- a/.github/workflows/production_pipeline.yml +++ b/.github/workflows/production_pipeline.yml @@ -42,8 +42,17 @@ jobs: DB_PASSWORD: password steps: - - name: Checkout + - name: Get latest release with tag + id: latestrelease + run: | + echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/weide-zhou/ticket13/releases/latest | jq '.tag_name' | sed 's/\"//g')" + - name: Confirm release tag + run: | + echo ${{ steps.latestrelease.outputs.releasetag }} + - name: Checkout tag uses: actions/checkout@v2 + with: + ref: ${{ steps.latestrelease.outputs.releasetag }} - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -71,8 +80,17 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - name: Checkout + - name: Get latest release with tag + id: latestrelease + run: | + echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/weide-zhou/ticket13/releases/latest | jq '.tag_name' | sed 's/\"//g')" + - name: Confirm release tag + run: | + echo ${{ steps.latestrelease.outputs.releasetag }} + - name: Checkout tag uses: actions/checkout@v2 + with: + ref: ${{ steps.latestrelease.outputs.releasetag }} - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -84,17 +102,51 @@ jobs: run: | bundle exec rubocop + audit: + name: Audit dependencies + runs-on: ubuntu-latest + steps: + - name: Get latest release with tag + id: latestrelease + run: | + echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/weide-zhou/ticket13/releases/latest | jq '.tag_name' | sed 's/\"//g')" + - name: Confirm release tag + run: | + echo ${{ steps.latestrelease.outputs.releasetag }} + - name: Checkout tag + uses: actions/checkout@v2 + with: + ref: ${{ steps.latestrelease.outputs.releasetag }} + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + # runs 'bundle install' and caches installed gems automatically + bundler-cache: true + + - name: Audit + run: | + bundle exec bundler-audit + deploy: name: Deploy runs-on: ubuntu-latest environment: 'production' - if: github.ref == 'refs/heads/main' - needs: [lint, test] + needs: [lint, test, audit] steps: - - name: Checkout code + - name: Get latest release with tag + id: latestrelease + run: | + echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/weide-zhou/ticket13/releases/latest | jq '.tag_name' | sed 's/\"//g')" + - name: Confirm release tag + run: | + echo ${{ steps.latestrelease.outputs.releasetag }} + - name: Checkout tag uses: actions/checkout@v2 + with: + ref: ${{ steps.latestrelease.outputs.releasetag }} - name: Install cf client env: