From ce5e195fe00d698aa92482a3890377f3aa1cc71a Mon Sep 17 00:00:00 2001 From: John Jeffers Date: Thu, 6 Jun 2024 14:32:54 -0600 Subject: [PATCH 1/3] add release workflow, update branch name --- .github/workflows/docs.yml | 32 +++++++++--------- .github/workflows/release.yaml | 60 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 30 +++++++++-------- 3 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 967ec0a..1ecc17d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,7 +2,8 @@ name: Generate Docs on: push: - branches: [ "master" ] + branches: + - main permissions: contents: write @@ -11,21 +12,20 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true - - name: Generate docs - run: | - rm -f doc/index.db - rdoc --format=markdown lib/fusionauth/fusionauth_client.rb - - - name: Commit - uses: EndBug/add-and-commit@v9 - with: - add: 'doc/' - message: ':memo: Updating docs' + - name: Generate docs + run: | + rm -f doc/index.db + rdoc --format=markdown lib/fusionauth/fusionauth_client.rb + - name: Commit + uses: EndBug/add-and-commit@v9 + with: + add: 'doc/' + message: ':memo: Updating docs' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8462875 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,60 @@ +# Run locally with act: +# +# act pull_request \ +# --platform fusionauth-builder=[ecr-repo-name]/fusionauth-builder:latest] \ +# --workflows ./.github/workflows/release.yaml \ +# --env-file <(aws configure export-credentials --profile [aws-profile] --format env) + +name: Release + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + release: + runs-on: fusionauth-builder + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: set aws credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::752443094709:role/github-actions + role-session-name: aws-auth-action + aws-region: us-west-2 + + - name: get secret + run: | + while IFS=$'\t' read -r key value; do + echo "::add-mask::${value}" + echo "${key}=${value}" >> $GITHUB_ENV + done < <(aws secretsmanager get-secret-value \ + --region us-west-2 \ + --secret-id platform/rubygems \ + --query SecretString \ + --output text | \ + jq -r 'to_entries[] | [.key, .value] | @tsv') + + - name: set gem credentials + run: | + mkdir -p ~/.gem + echo "${{ env.API_KEY }}" > ~/.gem/credentials + + - name: compile + if: github.event_name == 'pull_request' + shell: bash -l {0} + run: sb compile + + - name: publish + if: github.event_name == 'push' + shell: bash -l {0} + run: sb publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bd99ea..11ddec5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,11 @@ name: Test Library on: push: - branches: [ "master" ] + branches: + - main pull_request: - branches: [ "master" ] + branches: + - main permissions: contents: read @@ -13,19 +15,19 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up FusionAuth - working-directory: .github/fusionauth - run: docker compose up -d + - name: Set up FusionAuth + working-directory: .github/fusionauth + run: docker compose up -d - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true - - name: Waiting for FusionAuth App - run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false + - name: Waiting for FusionAuth App + run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false - - name: Run test suite - run: rake test + - name: Run test suite + run: rake test From 38fdff79aa0f8cd2921a8ae7acd1aba02694001a Mon Sep 17 00:00:00 2001 From: John Jeffers Date: Thu, 6 Jun 2024 15:33:47 -0600 Subject: [PATCH 2/3] update workflow --- .github/workflows/release.yaml | 42 +++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8462875..53f29fe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,11 +1,11 @@ # Run locally with act: # -# act pull_request \ +# act pull_request [--input command=[command]] \ # --platform fusionauth-builder=[ecr-repo-name]/fusionauth-builder:latest] \ # --workflows ./.github/workflows/release.yaml \ # --env-file <(aws configure export-credentials --profile [aws-profile] --format env) -name: Release +name: release on: push: @@ -14,12 +14,38 @@ on: pull_request: branches: - main + workflow_dispatch: + inputs: + command: + type: choice + options: + - build # build only + - publish # build & publish to rubygems + - release # build & release to svn + default: build permissions: contents: read jobs: - release: + build: + if: | + github.event_name == 'pull_request' || + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' && inputs.command == 'build' + runs-on: fusionauth-builder + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: compile + shell: bash -l {0} + run: sb compile + + deploy: + if: | + github.event_name == 'workflow_dispatch' && + (inputs.command == 'release' || inputs.command == 'publish') runs-on: fusionauth-builder steps: - name: checkout @@ -49,12 +75,12 @@ jobs: mkdir -p ~/.gem echo "${{ env.API_KEY }}" > ~/.gem/credentials - - name: compile - if: github.event_name == 'pull_request' + - name: release to svn + if: inputs.command == 'release' shell: bash -l {0} - run: sb compile + run: sb release - - name: publish - if: github.event_name == 'push' + - name: publish to rubygems + if: inputs.command == 'publish' shell: bash -l {0} run: sb publish From bd0677ae2a156ee7100ff718458464b17c1fc226 Mon Sep 17 00:00:00 2001 From: John Jeffers Date: Thu, 6 Jun 2024 15:35:38 -0600 Subject: [PATCH 3/3] rename workflow --- .github/workflows/{release.yaml => deploy.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{release.yaml => deploy.yaml} (99%) diff --git a/.github/workflows/release.yaml b/.github/workflows/deploy.yaml similarity index 99% rename from .github/workflows/release.yaml rename to .github/workflows/deploy.yaml index 53f29fe..d0ddf7e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/deploy.yaml @@ -5,7 +5,7 @@ # --workflows ./.github/workflows/release.yaml \ # --env-file <(aws configure export-credentials --profile [aws-profile] --format env) -name: release +name: Deploy on: push: