Skip to content

Commit

Permalink
Seperate GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
matchilling committed Jun 19, 2024
1 parent fd5e33d commit 1abb5d3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 67 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ on:
workflow_call:
inputs:
version:
required: false
description: Version to build
required: true
type: string

jobs:
env:
JAVA_DISTRIBUTION: zulu
JAVA_VERSION: 21

verification:
runs-on: ubuntu-20.04
jobs:
test:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
cache: 'gradle'
- run: |
./gradlew test
cache: gradle
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
ref: ${{ inputs.version }}
- run: ./gradlew test
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy

on:
workflow_call:
inputs:
version:
description: Version to deploy
required: true
type: string

env:
HEROKU_REGISTRY_TOKEN: ${{ secrets.HEROKU_REGISTRY_TOKEN }}
JAVA_DISTRIBUTION: zulu
JAVA_VERSION: 21

jobs:
deploy:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
cache: gradle
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
ref: ${{ inputs.version }}

- name: Login to Heroku Container Registry
uses: docker/login-action@v3
with:
password: ${{ env.HEROKU_REGISTRY_TOKEN }}
registry: registry.heroku.com
username: _

- name: Push image to Heroku registry
run: ./gradlew dockerPushHerokuProduction

- name: Trigger release
shell: bash
run: |
export IMAGE_ID=$(docker inspect registry.heroku.com/chucky/web --format={{.Id}})
curl -X PATCH \
https://api.heroku.com/apps/chucky/formation \
-H 'Accept: application/vnd.heroku+json; version=3.docker-releases' \
-H "Authorization: Bearer ${HEROKU_REGISTRY_TOKEN}" \
-H 'Content-Type: application/json' \
-d "{\"updates\":[{\"type\":\"web\",\"docker_image\":\"${IMAGE_ID}\"}]}"
18 changes: 18 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and deploy

on:
push:
branches: [ master ]

jobs:
build:
uses: ./.github/workflows/build.yml
with:
version: ${{ github.sha }}

deploy:
needs: build
secrets: inherit
uses: ./.github/workflows/deploy.yml
with:
version: ${{ github.sha }}
55 changes: 0 additions & 55 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CHUCKNORRIS.IO [![CircleCI](https://circleci.com/gh/chucknorris-io/chuck-api.svg?style=svg)](https://circleci.com/gh/chucknorris-io/chuck-api)
# CHUCKNORRIS.IO

[chucknorris.io](https://api.chucknorris.io) is a free JSON API for hand curated Chuck Norris facts.

Expand Down

0 comments on commit 1abb5d3

Please sign in to comment.