|
| 1 | +# Run locally with act: |
| 2 | +# |
| 3 | +# act pull_request [--input command=[command]] \ |
| 4 | +# --platform fusionauth-builder=[ecr-repo-name]/fusionauth-builder:latest] \ |
| 5 | +# --workflows ./.github/workflows/release.yaml \ |
| 6 | +# --env-file <(aws configure export-credentials --profile [aws-profile] --format env) |
| 7 | + |
| 8 | +name: Deploy |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + command: |
| 20 | + type: choice |
| 21 | + options: |
| 22 | + - build # build only |
| 23 | + - publish # build & publish to maven |
| 24 | + - release # build & release to svn |
| 25 | + default: build |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +jobs: |
| 31 | + build: |
| 32 | + if: | |
| 33 | + github.event_name == 'pull_request' || |
| 34 | + github.event_name == 'push' || |
| 35 | + github.event_name == 'workflow_dispatch' && inputs.command == 'build' |
| 36 | + runs-on: fusionauth-builder |
| 37 | + steps: |
| 38 | + - name: checkout |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: compile |
| 42 | + shell: bash -l {0} |
| 43 | + run: sb compile |
| 44 | + |
| 45 | + deploy: |
| 46 | + if: | |
| 47 | + github.event_name == 'workflow_dispatch' && |
| 48 | + (inputs.command == 'release' || inputs.command == 'publish') |
| 49 | + runs-on: fusionauth-builder |
| 50 | + steps: |
| 51 | + - name: checkout |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: set aws credentials |
| 55 | + uses: aws-actions/configure-aws-credentials@v4 |
| 56 | + with: |
| 57 | + role-to-assume: arn:aws:iam::752443094709:role/github-actions |
| 58 | + role-session-name: aws-auth-action |
| 59 | + aws-region: us-west-2 |
| 60 | + |
| 61 | + - name: get secret |
| 62 | + run: | |
| 63 | + while IFS=$'\t' read -r key value; do |
| 64 | + echo "::add-mask::${value}" |
| 65 | + echo "${key}=${value}" >> $GITHUB_ENV |
| 66 | + done < <(aws secretsmanager get-secret-value \ |
| 67 | + --region us-west-2 \ |
| 68 | + --secret-id platform/maven \ |
| 69 | + --query SecretString \ |
| 70 | + --output text | \ |
| 71 | + jq -r 'to_entries[] | [.key, .value] | @tsv') |
| 72 | +
|
| 73 | + - name: import gpg key |
| 74 | + run: | |
| 75 | + export GPG_TTY=$(tty) |
| 76 | + echo "${{ env.PRIV_KEY_B64 }}" | base64 -d > /tmp/key.asc |
| 77 | + echo "${{ env.PRIV_KEY_PASSWORD }}" | gpg --batch --yes --passphrase-fd 0 --import /tmp/key.asc |
| 78 | + rm /tmp/key.asc |
| 79 | +
|
| 80 | + # We need this to prevent 'gpg: signing failed: Timeout' error during 'sb publish' |
| 81 | + mkdir -p ~/.gnupg |
| 82 | + echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf |
| 83 | +
|
| 84 | + - name: configure maven settings.xml |
| 85 | + shell: bash -l {0} |
| 86 | + run: | |
| 87 | + export KEY_NAME="FusionAuth Platform Team" |
| 88 | + export PASSPHRASE="${{ env.PRIV_KEY_PASSWORD }}" |
| 89 | + export OSSRH_USERNAME="${{ env.OSSRH_USERNAME }}" |
| 90 | + export OSSRH_PASSWORD="${{ env.OSSRH_PASSWORD }}" |
| 91 | + export BREWDIR="/usr" |
| 92 | + envsubst < ~/dev/inversoft/fusionauth/fusionauth-developer/setup/modules/files/maven/settings.xml > ~/.m2/settings.xml |
| 93 | +
|
| 94 | + - name: release to svn |
| 95 | + if: inputs.command == 'release' |
| 96 | + shell: bash -l {0} |
| 97 | + run: sb release |
| 98 | + |
| 99 | + - name: publish to maven |
| 100 | + if: inputs.command == 'publish' |
| 101 | + shell: bash -l {0} |
| 102 | + run: | |
| 103 | + export GPG_TTY=$(tty) |
| 104 | + sb publish |
0 commit comments