-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from navikt/ci/setup-deploy-backend
[WIP] Justering av workflows
- Loading branch information
Showing
13 changed files
with
319 additions
and
176 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build | ||
|
||
on: [pull_request] | ||
env: | ||
NODE_VERSION: "14.x" | ||
|
||
jobs: | ||
change-check: | ||
name: Check changes | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed-be: ${{ steps.changed-be.outputs.changed }} | ||
changed-fe: ${{ steps.changed-fe.outputs.changed }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 100 | ||
- name: Backend | ||
uses: marceloprado/has-changed-path@v1 | ||
id: changed-be | ||
with: | ||
paths: backend | ||
- name: Frontend | ||
uses: marceloprado/has-changed-path@v1 | ||
id: changed-fe | ||
with: | ||
paths: frontend | ||
build-be: | ||
name: Build (backend) | ||
runs-on: ubuntu-latest | ||
needs: change-check | ||
if: needs.change-check.outputs.changed-be == 'true' | ||
defaults: | ||
run: | ||
working-directory: backend | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: "adopt" | ||
java-version: 11 | ||
cache: "gradle" | ||
- name: Build with Gradle | ||
run: ./gradlew test build --info | ||
- name: Publish test report | ||
uses: ScaCap/action-surefire-report@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
report_paths: "**/build/test-results/test/TEST-*.xml" | ||
build-fe: | ||
name: Build (frontend) | ||
runs-on: ubuntu-latest | ||
needs: change-check | ||
if: needs.change-check.outputs.changed-fe == 'true' | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
- name: Install and build | ||
run: | | ||
npm ci | ||
npm run build | ||
# TODO: Enable when MSW/Docker scope is up | ||
# - name: Cypress run | ||
# uses: cypress-io/github-action@v2 | ||
# with: | ||
# working-directory: frontend | ||
# browser: chrome | ||
# headless: true | ||
# wait-on: http://localhost:3000 | ||
# start: npm start |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: Deploy (dev) | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
IMAGE: ghcr.io/navikt/mulighetsrommet | ||
IMAGE_LABEL: dev | ||
REACT_APP_BACKEND_API_ROOT: https://amt-informasjon-flate.dev.intern.nav.no | ||
CI: true | ||
TZ: Europe/Amsterdam | ||
NODE_VERSION: "14.x" | ||
|
||
jobs: | ||
change-check: | ||
name: Check changes | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed-be: ${{ steps.changed-be.outputs.changed }} | ||
changed-fe: ${{ steps.changed-fe.outputs.changed }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 100 | ||
- name: Backend | ||
uses: marceloprado/has-changed-path@v1 | ||
id: changed-be | ||
with: | ||
paths: backend | ||
- name: Frontend | ||
uses: marceloprado/has-changed-path@v1 | ||
id: changed-fe | ||
with: | ||
paths: frontend | ||
build-docker-image-be: | ||
name: Build Docker image (backend) | ||
runs-on: ubuntu-latest | ||
needs: change-check | ||
if: needs.change-check.outputs.changed-be == 'true' | ||
defaults: | ||
run: | ||
working-directory: backend | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: "adopt" | ||
java-version: 11 | ||
- name: Apply gradle cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Build with Gradle | ||
run: ./gradlew test build --info | ||
- name: Build and push Docker image | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} --password-stdin | ||
echo ${GITHUB_TOKEN} | docker login ghcr.io -u ${{github.actor}} --password-stdin | ||
docker build -t ${IMAGE}-api-${IMAGE_LABEL}:${IMAGE_TAG} . | ||
docker push ${IMAGE}-api-${IMAGE_LABEL}:${IMAGE_TAG} | ||
deploy-be: | ||
name: Deploy Docker image (backend) | ||
runs-on: ubuntu-latest | ||
needs: build-docker-image-be | ||
defaults: | ||
run: | ||
working-directory: backend | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Deploy | ||
uses: nais/deploy/actions/deploy@v1 | ||
env: | ||
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | ||
CLUSTER: dev-gcp | ||
RESOURCE: backend/.nais/nais.yaml | ||
VARS: backend/.nais/dev-gcp.yaml | ||
VAR: image_tag=${{env.IMAGE_TAG}},image_label=${{env.IMAGE_LABEL}} | ||
- name: Create release tag | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: release/dev@${{ env.IMAGE_TAG }} | ||
release_name: Release to dev | ||
prerelease: true | ||
build-docker-image-fe: | ||
name: Build Docker image (frontend) | ||
runs-on: ubuntu-latest | ||
needs: change-check | ||
if: needs.change-check.outputs.changed-fe == 'true' | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
- name: Install and build | ||
run: | | ||
npm ci | ||
npm run build | ||
- name: Build and publish Docker image | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} --password-stdin | ||
echo ${GITHUB_TOKEN} | docker login ghcr.io -u ${{github.actor}} --password-stdin | ||
docker build -t ${IMAGE}-flate-${IMAGE_LABEL}:${IMAGE_TAG} -f .docker/dev/Dockerfile . | ||
docker push ${IMAGE}-flate-${IMAGE_LABEL}:${IMAGE_TAG} | ||
deploy-fe: | ||
name: Deploy Docker image (frontend) | ||
runs-on: ubuntu-latest | ||
needs: build-docker-image-fe | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
- uses: nais/deploy/actions/deploy@v1 | ||
env: | ||
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | ||
CLUSTER: dev-gcp | ||
RESOURCE: frontend/.nais/nais.yaml | ||
VARS: frontend/.nais/dev-gcp.yaml | ||
VAR: image_tag=${{env.IMAGE_TAG}},image_label=${{env.IMAGE_LABEL}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
63 changes: 30 additions & 33 deletions
63
.github/workflows/fe_deploy-labs.yaml → .github/workflows/deploy-labs.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,72 @@ | ||
name: Deploy (labs) - Frontend | ||
name: Deploy (labs) | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
IMAGE: ghcr.io/navikt/mulighetsrommet | ||
IMAGE_LABEL: labs | ||
RESOURCE: .nais/nais.yaml | ||
REACT_APP_BACKEND_API_ROOT: '' | ||
REACT_APP_BACKEND_API_ROOT: "" | ||
CI: true | ||
TZ: Europe/Amsterdam | ||
NODE_VERSION: '14.x' | ||
NODE_VERSION: "14.x" | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
change-check: | ||
name: Check changes | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed-fe: ${{ steps.changed-fe.outputs.changed }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run tests | ||
run: npm run test | ||
build: | ||
name: Build Project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
fetch-depth: 100 | ||
- name: Frontend | ||
uses: marceloprado/has-changed-path@v1 | ||
id: changed-fe | ||
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
- run: npm ci | ||
- run: npm run build | ||
|
||
paths: frontend | ||
build-docker-image: | ||
runs-on: ubuntu-latest | ||
name: Build and publish Docker image | ||
needs: [build, test] | ||
name: Build Docker image | ||
needs: change-check | ||
if: needs.change-check.outputs.changed-fe == 'true' | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
- name: Install production artifact | ||
run: npm ci | ||
- name: Build production artifact | ||
run: npm run build:labs | ||
- name: Install and build | ||
run: | | ||
npm ci | ||
npm run build:labs | ||
- name: Build and publish Docker image | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} --password-stdin | ||
echo ${GITHUB_TOKEN} | docker login ghcr.io -u ${{github.actor}} --password-stdin | ||
docker build -t ${IMAGE}-${IMAGE_LABEL}:${IMAGE_TAG} -f .docker/labs/Dockerfile . | ||
docker push ${IMAGE}-${IMAGE_LABEL}:${IMAGE_TAG} | ||
docker build -t ${IMAGE}-flate-${IMAGE_LABEL}:${IMAGE_TAG} -f .docker/labs/Dockerfile . | ||
docker push ${IMAGE}-flate-${IMAGE_LABEL}:${IMAGE_TAG} | ||
deploy-labs: | ||
name: Deploy application to labs | ||
needs: | ||
- build-docker-image | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: nais/deploy/actions/deploy@v1 | ||
env: | ||
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | ||
CLUSTER: labs-gcp | ||
PRINT_PAYLOAD: true | ||
VARS: .nais/labs-gcp.yaml | ||
RESOURCE: frontend/.nais/nais.yaml | ||
VARS: frontend/.nais/labs-gcp.yaml | ||
VAR: image_tag=${{env.IMAGE_TAG}},image_label=${{env.IMAGE_LABEL}} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.