Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Optimize ci
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Mar 25, 2021
1 parent 224c433 commit 6091a71
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 93 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ on:
jobs:

test:
name: Test with on ${{ matrix.os }}
runs-on: ${{matrix.os}}
if: github.event.head_commit.author.name != 'actions'
strategy:
matrix:
#os: [ windows-latest, ubuntu-latest ]
os: [ ubuntu-latest ]
name: Test with on ${{ matrix.os }}
outputs:
keycloakify_version: ${{ steps.step1.outputs.out }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -29,6 +31,11 @@ jobs:
with:
name: build
path: build
- id: step1
run: |
echo ::set-output name=out::$(
node -e 'console.log(require("./node_modules/keycloakify/package.json")["version"])'
)
check_if_version_upgraded:
name: Check if version upgrade
Expand Down Expand Up @@ -97,7 +104,9 @@ jobs:
build_keycloak_theme:
name: Build keycloak theme
runs-on: ubuntu-latest
needs: check_if_version_upgraded
needs:
- check_if_version_upgraded
- test
if: ${{ needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' }}
steps:
- uses: actions/checkout@v2
Expand All @@ -108,8 +117,11 @@ jobs:
with:
name: build
path: build
- run: yarn --frozen-lockfile
- run: npx build-keycloak-theme --external-assets
#- run: yarn --frozen-lockfile
#- run: npx build-keycloak-theme --external-assets
- run: npx -y -p keycloakify@$VER build-keycloak-theme --external-assets
env:
VER: ${{ needs.test.outputs.keycloakify_version }}
- name: Upload keycloak theme
uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ RUN yarn build
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
16 changes: 10 additions & 6 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#This is an alternative Dockerfile that aims to speed up
#to be used in the CI pipeline.
#To avoid having to build the app over and over, instead of
#re building the app in the fist stage as we do in ./Dockerfile
#we symply copy over from a assumed pre existing ./build.tar file.
# This is an alternative Dockerfile
# that aims to be used in the CI pipeline.
# The ./Dockerfile would work just fine in CI but we
# save some time by symply coping over the build folder
# from the context.
# On top of that if we use build-keycloak-theme --external-assets
# we need to have exactly the same build (or build/static/js/main.[hash].chunk.js
# could have changed.

# build environment
FROM node:14.16.0-alpine as build
WORKDIR /app
#We use ADD instead of COPY because build/ is in .dockerignore
ADD build.tar build
COPY nginx.conf .

# production environment
# production environment (copy pasted from ./Dockerfile)
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
This repo constitutes an easily reusable CI setup for React App in general, and Apps that generates Keycloaks's theme
using [keycloakify](https://github.com/InseeFrLab/keycloakify) in particular.

- This CI is configured to both publish on [github-pages](https://github.com/garronej/keycloakify-demo-app/blob/224c43383548635a463fa68e8909c147ac189f0e/.github/workflows/ci.yaml#L172-L187) and on [DockerHub](https://github.com/garronej/keycloakify-demo-app/blob/224c43383548635a463fa68e8909c147ac189f0e/.github/workflows/ci.yaml#L56-L94). In practice you probably want one
or the other but not both.
- To release **don't create a tag manually**, the CI do it for you. Just update the `package.json`'s version field and push.
- The `.jar` files that bundle the Keycloak theme will be attached as an asset with every GitHub release. [Example](https://github.com/InseeFrLab/keycloakify-demo-app/releases/tag/v0.1.0)).
- The CI publishes the app docker image on DockerHub. `<org>/<repo>:main` for each **commit** on `main`, `<org>/<repo>:<feature-branch-name>` for each **pull-request** on `main`
Expand All @@ -25,6 +27,12 @@ repository ``Settings`` tab, then ``Secrets`` you will need to add two new secre
- ``DOCKERHUB_TOKEN``, you Dockerhub authorization token.
- ``DOCKERHUB_USERNAME``, Your Dockerhub username.

# About keycloakify





# Notes for self

docker build -f Dockerfile.ci -t garronej/keycloakify-demo-app:test .
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"homepage": "https://garronej.github.io/keycloakify-demo-app",
"name": "keycloakify-demo-app",
"version": "0.2.3",
"version": "0.2.4",
"description": "A demo project for keycloakify",
"repository": {
"type": "git",
Expand All @@ -22,7 +22,7 @@
"react-dom": "^17.0.1",
"tss-react": "^0.0.11",
"web-vitals": "^1.0.1",
"keycloakify": "^0.3.8"
"keycloakify": "^0.3.9"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
Expand Down
Loading

0 comments on commit 6091a71

Please sign in to comment.