Skip to content

Commit

Permalink
Fix GitHub Actions (#27)
Browse files Browse the repository at this point in the history
Fix all GH actions so they run properly and produce the desired result.
  • Loading branch information
aegan123 authored Feb 17, 2024
1 parent ea67e20 commit 1bc0b97
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 42 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/build-artifacts-on-tag-and-on-develop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish a Docker image
name: Build and publish container images
on:
push:
tags:
Expand All @@ -7,10 +7,10 @@ on:
- 'develop'
jobs:
eventsignup_backend-image:
name: Build & push docker image
name: Build & push container image
runs-on: ubuntu-latest
env:
IMG_NAME: ${{ github.repository }}
IMG_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -19,7 +19,7 @@ jobs:
run: |
echo "github.ref -> {{ github.ref }}"
- name: Docker metadata
- name: Container metadata
id: metadata
uses: docker/metadata-action@v3
with:
Expand All @@ -29,37 +29,43 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
- name: Log in to Docker Hub
uses: docker/[email protected]
if: ${{ github.ref_type == 'tag' }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.gh_user }}
password: ${{ secrets.gh_token }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
- name: Build and push container image
uses: docker/build-push-action@v5.1.0
with:
context: .
file: Dockerfile
push: ${{ github.event.base_ref =='refs/heads/main' && github.ref_type == 'tag' && !startsWith(github.ref, 'refs/tags/v0.')}}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

typescript-types:
runs-on: ubuntu-latest
container: eclipse-temurin:21
env:
MONGO_HOST: localhost
MONGO_HOST: mongodb
KEYCLOAK_URL: localhost
SPRING_PROFILES_ACTIVE: dev
GIT_TAG: ${GITHUB_REF_NAME}
services:
mongodb:
image: mongo:5.0.5
ports:
- 27017:27017
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: '5.0.5'

- name: Authenticate to github packages
run: echo '//npm.pkg.github.com/:_authToken=${{ secrets.gh_token }}' > ~/.npmrc

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: '5.0'
mongodb-version: '5.0.5'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0
- name: Run unit tests
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ node {
openApi {
apiDocsUrl.set("http://localhost:8080/v1/api-docs")
customBootRun {
args.set(["--spring.profiles.active=special"])
args = ["--spring.profiles.active=special"]
}
}

Expand Down Expand Up @@ -81,7 +81,12 @@ tasks.register('generateTsTypes', NpxTask) {
}

tasks.register('generateTypesVersionNumber', NpmTask) {
args = ["version", new Date().format('yyyyMMdd') + "." + new Date().format('HHmm') + ".0"]
def tag = System.getenv("GIT_TAG")
if (tag && tag =~ '[0-9]+.[0-9]+.[0-9]+') {
args = ["version", tag.substring(1)]
} else {
args = ["version", new Date().format('yyyyMMdd') + "." + new Date().format('HHmm') + ".0"]
}
}

tasks.register('publishTypesPlugin', NpmTask) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@ fi.asteriski.config.security.allowed-cors-domain=${ALLOWED_CORS_DOMAIN}
fi.asteriski.config.security.logout-redirect-url=${LOGOUT_URL}

## keycloak
spring.security.oauth2.client.provider.external.issuer-uri=${KEYCLOAK_ISSUER_URI}
# keycloak
keycloak.realm=asteriski
keycloak.auth-server-url=${KEYCLOAK_URL}
keycloak.resource=eventsignup_backend
keycloak.bearer-only=true
keycloak.use-resource-role-mappings=false
keycloak.principal-attribute=preferred_username

spring.security.oauth2.client.provider.external.issuer-uri=${KEYCLOAK_ISSUER_URI}
spring.security.oauth2.client.registration.external.provider=external
spring.security.oauth2.client.registration.external.scope=openid,offline_access,profile
spring.security.oauth2.client.registration.external.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.external.client-name=e${KEYCLOAK_CLIENT_NAME}
spring.security.oauth2.client.registration.external.client-id=${KEYCLOAK_CLIENT_ID}
spring.security.oauth2.client.registration.external.client-secret=${KEYCLOAK_CLIENT_SECRET}
4 changes: 0 additions & 4 deletions src/main/resources/application-special.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
spring.data.mongodb.host=localhost
# OpenApi
springdoc.api-docs.enabled=true
springdoc.api-docs.path=/v1/api-docs
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.enabled=true
springdoc.swagger-ui.use-root-path=false
# Quartz config
org.quartz.jobStore.mongoUri=mongodb://localhost:27017
org.quartz.jobStore.dbName=eventsignup
18 changes: 0 additions & 18 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,3 @@ fi.asteriski.config.email.default-sender-address=noreply@localhost
fi.asteriski.config.archiving.days-to-archive-past-events=180
fi.asteriski.config.security.allowedCorsDomain=http://localhost:3000
fi.asteriski.config.email.baseUrl=https://ilmot.asteriski.fi

# keycloak
keycloak.realm=asteriski
keycloak.auth-server-url=${KEYCLOAK_URL}
keycloak.resource=eventsignup_backend
keycloak.bearer-only=true
keycloak.use-resource-role-mappings=false
keycloak.principal-attribute=preferred_username

## keycloak
spring.security.oauth2.client.provider.external.issuer-uri=http://localhost:9090/realms/asteriski

spring.security.oauth2.client.registration.external.provider=external
spring.security.oauth2.client.registration.external.client-name=eventsignup_backend
spring.security.oauth2.client.registration.external.client-id=eventsignup_backend
spring.security.oauth2.client.registration.external.client-secret=(put your client secret here)
spring.security.oauth2.client.registration.external.scope=openid,offline_access,profile
spring.security.oauth2.client.registration.external.authorization-grant-type=authorization_code

0 comments on commit 1bc0b97

Please sign in to comment.