Skip to content

Commit

Permalink
Change deploy strategy (#9)
Browse files Browse the repository at this point in the history
* Change deploy strategy
  • Loading branch information
alik-agaev authored Sep 24, 2024
1 parent 3a9612f commit 099c145
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:

name: Build and push docker

Expand All @@ -21,19 +18,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand All @@ -54,8 +38,8 @@ jobs:
with:
context: "."
file: "Dockerfile"
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/validate-image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
pull_request:
branches:
- main

name: Build docker image

env:
REGISTRY: ghcr.io
IMAGE_NAME: blockscout/chainscout

jobs:
validate-build:
name: Docker build
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v6
with:
context: "."
file: "Dockerfile"
push: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 099c145

Please sign in to comment.