Skip to content

Commit

Permalink
ci: refactor prod release
Browse files Browse the repository at this point in the history
  • Loading branch information
mmpetarpeshev committed Feb 29, 2024
1 parent 3e9c64a commit 87c1de8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 42 deletions.
31 changes: 10 additions & 21 deletions .github/workflows/prod-docker-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
release:
types: [created]

env:
ENV: "prd"
Expand All @@ -23,28 +21,24 @@ jobs:
fetch-depth: 100
ref: ${{ github.event.pull_request.head.sha }}

- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: ""
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"ci","section":"CI / CD","hidden":false},{"type":"test","section":"Testing","hidden":false},{"type":"refactor","section":"Refactorings","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
- name: Get tags
run: git fetch --tags origin

- name: Get latest release tag
shell: bash
id: release_tag
run: echo TAG=$(git describe --tags HEAD --abbrev=0) >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
id: buildx
# Use the action from the master, as we've seen some inconsistencies with @v1
# Issue: https://github.com/docker/build-push-action/issues/286
uses: docker/setup-buildx-action@master
# Only worked for us with this option on �‍♂️
with:
install: true

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
# Key is named differently to avoid collision
key: ${{ runner.os }}-${{ env.ENV }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.ENV }}-buildx
Expand All @@ -64,10 +58,7 @@ jobs:
with:
images: aeternitybot/dex-backend-mainnet
tags: |
type=raw,value=latest,enable=${{ endsWith(GitHub.ref, 'main') }}
type=raw,value=${{ steps.release.outputs.tag_name }},enable=${{ endsWith(GitHub.ref, 'main') }}
type=ref,event=tag
type=ref,event=pr
type=raw,value=${{ steps.release_tag.outputs.TAG }}
- name: Build and push docker image
if: |
Expand All @@ -81,9 +72,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
# Note the mode=max here
# More: https://github.com/moby/buildkit#--export-cache-options
# And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Move cache
Expand All @@ -104,7 +92,8 @@ jobs:
if: ${{ steps.release.outputs.release_created }}
uses: aeternity/ae-github-actions/argocd-deploy@v4
with:
url-prefix: ${{ steps.release.outputs.tag_name }}
git-sha: ${{ steps.git-sha.outputs.GIT_SHA }}
url-prefix: ${{ steps.release_tag.outputs.TAG }}}
env: ${{ env.ENV }}
app: ${{ env.APP }}

Expand Down
31 changes: 10 additions & 21 deletions .github/workflows/prod-docker-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
release:
types: [created]

env:
ENV: "prd"
Expand All @@ -23,28 +21,24 @@ jobs:
fetch-depth: 100
ref: ${{ github.event.pull_request.head.sha }}

- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: ""
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"ci","section":"CI / CD","hidden":false},{"type":"test","section":"Testing","hidden":false},{"type":"refactor","section":"Refactorings","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
- name: Get tags
run: git fetch --tags origin

- name: Get latest release tag
shell: bash
id: release_tag
run: echo TAG=$(git describe --tags HEAD --abbrev=0) >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
id: buildx
# Use the action from the master, as we've seen some inconsistencies with @v1
# Issue: https://github.com/docker/build-push-action/issues/286
uses: docker/setup-buildx-action@master
# Only worked for us with this option on �‍♂️
with:
install: true

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
# Key is named differently to avoid collision
key: ${{ runner.os }}-${{ env.ENV }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.ENV }}-buildx
Expand All @@ -64,10 +58,7 @@ jobs:
with:
images: aeternitybot/dex-backend-testnet
tags: |
type=raw,value=latest,enable=${{ endsWith(GitHub.ref, 'main') }}
type=raw,value=${{ steps.release.outputs.tag_name }},enable=${{ endsWith(GitHub.ref, 'main') }}
type=ref,event=tag
type=ref,event=pr
type=raw,value=${{ steps.release_tag.outputs.TAG }}
- name: Build and push docker image
if: |
Expand All @@ -81,9 +72,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
# Note the mode=max here
# More: https://github.com/moby/buildkit#--export-cache-options
# And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Move cache
Expand All @@ -104,7 +92,8 @@ jobs:
if: ${{ steps.release.outputs.release_created }}
uses: aeternity/ae-github-actions/argocd-deploy@v4
with:
url-prefix: ${{ steps.release.outputs.tag_name }}
git-sha: ${{ steps.git-sha.outputs.GIT_SHA }}
url-prefix: ${{ steps.release_tag.outputs.TAG }}
env: ${{ env.ENV }}
app: ${{ env.APP }}

Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Production Dex Backend Release

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
name: Release Please

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Release Please Action
id: release
uses: GoogleCloudPlatform/release-please-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: ""
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"ci","section":"CI / CD","hidden":false},{"type":"test","section":"Testing","hidden":false},{"type":"refactor","section":"Refactorings","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'

0 comments on commit 87c1de8

Please sign in to comment.