Skip to content

Commit

Permalink
Make build into reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ccremer committed Dec 16, 2021
1 parent 9c5cf30 commit 8827106
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PullRequest

on:
pull_request: {}

jobs:

build:
uses: appuio/cloud-portal/.github/workflows/template-build.yaml@preview-deployments
with:
namespace: appuio-cloud-preview
push_image: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}

deploy:
# Don't deploy with Renovate PRs
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
uses: appuio/cloud-portal/.github/workflows/template-deploy.yaml@preview-deployments
with:
namespace: appuio-cloud-preview
helm_release_name: portal-pr-${{ github.event.number }}
image_tag: pr-${{ github.event.number }}
revision: ${{ github.event.pull_request.head.sha }}
secrets:
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
needs:
- build
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: Build

on:
push:
branches:
- master
pull_request: {}
workflow_call:
inputs:
namespace:
type: string
required: true
push_image:
type: boolean
required: false
default: false

env:
REGISTRY: registry.cloudscale-lpg-2.appuio.cloud
Expand Down Expand Up @@ -33,7 +36,7 @@ jobs:
- run: npm ci
- run: npm run test

build:
dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -51,7 +54,7 @@ jobs:
e2e:
runs-on: ubuntu-latest
needs:
- build
- dist
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand All @@ -70,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
environment: preview
needs:
- build
- dist
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand All @@ -83,9 +86,10 @@ jobs:
uses: docker/metadata-action@v3
with:
# by default, it creates the `:pr-#` tag in pull requests and branch name on `master`
images: ${{ env.REGISTRY }}/appuio-cloud-preview/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ inputs.namespace }}/${{ env.IMAGE_NAME }}

- name: Docker login
if: ${{ inputs.push_image }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -96,19 +100,6 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
push: true
push: ${{ inputs.push_image }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
uses: appuio/cloud-portal/.github/workflows/template-deploy.yaml@preview-deployments
with:
namespace: appuio-cloud-preview
helm_release_name: portal-pr-${{ github.event.number }}
image_tag: pr-${{ github.event.number }}
revision: ${{ github.event.pull_request.head.sha }}
secrets:
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
needs:
- docker

0 comments on commit 8827106

Please sign in to comment.