Fix add to Slack website button and update documentation (#99) #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deployment (GCP) | |
on: | |
push: | |
branches: [ master ] | |
env: | |
# Required for CI workflow | |
JAVA_VERSION: "15" | |
JAVA_DISTRIBUTION: "zulu" | |
GCP_SERVICE: service-app | |
GCP_REGION: europe-west1 | |
GCP_REPOSITORY: thecodinglove | |
GCP_REPOSITORY_FORMAT: docker | |
GCP_REPOSITORY_IMAGE: thecodinglove-image | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
GCP_SA_KEY_DEPLOY: ${{ secrets.GCP_SA_KEY_DEPLOY }} | |
# Required for build | |
GCP_SA_KEY_APP: ${{ secrets.GCP_SA_KEY_APP }} | |
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} | |
SLACK_REQUEST_VERIFICATION_ENABLED: ${{ secrets.SLACK_REQUEST_VERIFICATION_ENABLED }} | |
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }} | |
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }} | |
SLACK_INTERACTIVITY_PUBSUB_TOPIC: ${{ secrets.SLACK_INTERACTIVITY_PUBSUB_TOPIC }} | |
SLACK_SLASH_COMMAND_PUBSUB_TOPIC: ${{ secrets.SLACK_SLASH_COMMAND_PUBSUB_TOPIC }} | |
SLACK_MONITORING_URL: ${{ secrets.SLACK_MONITORING_URL }} | |
APP_LOG_LEVEL: ${{ secrets.APP_LOG_LEVEL }} | |
APP_NETWORK_HTML_LOG_LEVEL: ${{ secrets.APP_NETWORK_HTML_LOG_LEVEL }} | |
APP_NETWORK_JSON_LOG_LEVEL: ${{ secrets.APP_NETWORK_JSON_LOG_LEVEL }} | |
APP_PUBLIC_URL: ${{ secrets.APP_PUBLIC_URL }} | |
SEARCH_PRELOAD_PUBSUB_TOPIC: ${{ secrets.SEARCH_PRELOAD_PUBSUB_TOPIC }} | |
jobs: | |
jsDeploy: | |
runs-on: ubuntu-20.04 | |
concurrency: | |
group: ${{ github.ref }}_jsDeploy | |
cancel-in-progress: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Set up Gradle cache | |
uses: gradle/gradle-build-action@v2 # By default, cache is only saved on the 'master' branch | |
- name: Set up deploy authentication | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: ${{ env.GCP_SA_KEY_DEPLOY }} | |
- name: Set up deploy cli | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: ${{ env.GCP_PROJECT_ID }} | |
- name: Set up container storage | |
run: |- | |
if [ "$(gcloud artifacts repositories describe ${{ env.GCP_REPOSITORY }} --location=${{ env.GCP_REGION }} >&/dev/null ; echo $?)" -ne 0 ]; then | |
echo "Creating new artifact registry repository" | |
gcloud artifacts repositories create ${{ env.GCP_REPOSITORY }} --location=${{ env.GCP_REGION }} --repository-format=${{ env.GCP_REPOSITORY_FORMAT }} | |
else | |
echo "Artifact registry repository already exists" | |
fi | |
- name: Set up deploy environment | |
run: | | |
GCP_BUILD_TAG="${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.GCP_REPOSITORY_IMAGE }}" | |
echo "GCP_BUILD_TAG=$GCP_BUILD_TAG" >> $GITHUB_ENV | |
- name: Build project | |
run: | | |
set -o pipefail && | |
bash ./scripts/env.sh && | |
./gradlew --no-daemon assemble | |
- name: Build container image | |
run: |- | |
docker build -t $GCP_BUILD_TAG . | |
- name: Push container image | |
run: |- | |
gcloud auth configure-docker ${{ env.GCP_REGION }}-docker.pkg.dev | |
docker build -t $GCP_BUILD_TAG . | |
docker push $GCP_BUILD_TAG | |
- name: Deploy | |
id: deployment | |
uses: google-github-actions/[email protected] | |
with: | |
service: ${{ env.GCP_SERVICE }} | |
image: ${{ env.GCP_BUILD_TAG }} | |
region: ${{ env.GCP_REGION }} | |
- name: Allow public access | |
run: | | |
gcloud run services add-iam-policy-binding ${{ env.GCP_SERVICE }} \ | |
--platform managed \ | |
--region ${{ env.GCP_REGION }} \ | |
--member=allUsers \ | |
--role=roles/run.invoker | |
- name: Artifacts | |
uses: actions/upload-artifact@v3 | |
if: always() # Ensure all artifacts are collected, even after errors | |
with: | |
name: Build | |
path: | | |
build/bin | |
local.properties | |
local-credentials-gcp.json | |
jsTest: | |
runs-on: ubuntu-20.04 | |
concurrency: | |
group: ${{ github.ref }}_jsTest | |
cancel-in-progress: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Set up Gradle cache | |
uses: gradle/gradle-build-action@v2 | |
- name: Test | |
run: | | |
set -o pipefail && | |
bash ./scripts/env.sh && | |
./gradlew --no-daemon --continue jsNodeTest | |
- name: Generate test report | |
uses: mikepenz/action-junit-report@v3 | |
if: always() # Ensure all test reports are collected, even after errors | |
with: | |
report_paths: '**/build/test-results/**/TEST-*.xml' | |
check_name: 'jsTestResults' | |
- name: Artifacts | |
uses: actions/upload-artifact@v3 | |
if: always() # Ensure all artifacts are collected, even after errors | |
with: | |
name: Tests | |
path: '**/build/test-results/**/TEST-*.xml' |