Skip to content

Merge pull request #57 from hellosign/fetch-ci-secrets-from-aws-sm #133

Merge pull request #57 from hellosign/fetch-ci-secrets-from-aws-sm

Merge pull request #57 from hellosign/fetch-ci-secrets-from-aws-sm #133

# This workflow will build the project, run integration tests, and release.
# Secret-backed jobs fetch credentials from AWS Secrets Manager using GitHub OIDC.
name: Build, Check, Publish
on:
push:
branches: [ main ]
paths-ignore:
- '.github/workflows/**'
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Configure AWS credentials for Docker Hub secrets (OIDC)
if: github.event_name != 'pull_request'
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::301904545275:role/oidc-github-hellosign-dropbox-sign-java-branch-main
aws-region: us-west-2
- name: Get Docker Hub secrets from AWS Secrets Manager
if: github.event_name != 'pull_request'
uses: aws-actions/aws-secretsmanager-get-secrets@v3
with:
secret-ids: |
DOCKER_USERNAME,github-actions/hellosign/shared/docker-username
DOCKER_TOKEN,github-actions/hellosign/shared/docker-token
parse-json-secrets: false
- name: Build SDK
run: ./run-build
- name: Ensure no changes in Generated Code
run: ./bin/check-clean-git-status
# This job runs on merging to "main" branch
# Builds and publishes package
publish-prod:
runs-on: ubuntu-latest
if: >-
github.repository == 'hellosign/dropbox-sign-java'
&& github.ref == 'refs/heads/main'
&& github.event_name != 'pull_request'
needs: [ build ]
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- name: Retrieve version
run: echo "PACKAGE_VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Configure AWS credentials for Maven secrets (OIDC)
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::521590706193:role/oidc-github-hellosign-dropbox-sign-java-branch-main
aws-region: us-west-2
- name: Get Maven Central secrets from AWS Secrets Manager
uses: aws-actions/aws-secretsmanager-get-secrets@v3
with:
secret-ids: |
SONATYPE_USERNAME,sdk-release-maven-central-token-username
SONATYPE_PASSWORD,sdk-release-maven-central-token-password
SIGNING_KEY,sdk-release-signing-key
SIGNING_PASSWORD,sdk-release-signing-password
parse-json-secrets: false
- name: Publish to Maven Central
run: ./gradlew publishAndReleaseToMavenCentral --no-daemon --no-parallel --no-configuration-cache --stacktrace
if: "!endsWith(env.PACKAGE_VERSION, '-SNAPSHOT')"
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ env.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ env.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ env.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ env.SIGNING_PASSWORD }}
- name: Publish Snapshot
run: ./gradlew publishToMavenCentral --no-daemon --no-parallel --no-configuration-cache --stacktrace
if: "endsWith(env.PACKAGE_VERSION, '-SNAPSHOT')"
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ env.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ env.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ env.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ env.SIGNING_PASSWORD }}
# This job runs on merging to "main" branch
# Creates a new tag using the value in the VERSION file
cut-tag:
runs-on: ubuntu-latest
if: >-
github.repository == 'hellosign/dropbox-sign-java'
&& github.ref == 'refs/heads/main'
&& github.event_name != 'pull_request'
needs: [ publish-prod ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Retrieve version
run: echo "PACKAGE_VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v6
if: "!endsWith(env.PACKAGE_VERSION, '-SNAPSHOT')"
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/" + process.env.PACKAGE_VERSION,
sha: context.sha
})