Skip to content

Commit

Permalink
ci: push image to ecr (#7)
Browse files Browse the repository at this point in the history
* feat: push image to ECR

* fix: removed cache

* ci: updated deprecated github actions output

* ci: generate image tag with metadata action

* ci: remove test branch in workflow

* ci: remove unused output steps

* ci: added missing id for step

* ci: updated step names

* ci: added cache

* ci: added test branch for github actions

* ci: added builder into github actions

* ci: local cache for gh actions

* ci: github workspace as cache

* ci: removed _build cache

* ci: run #2

* ci: removed translation key check

* ci: removed test branch from gh actions

Co-authored-by: charliecys <[email protected]>
  • Loading branch information
charliecys and charliecys authored Nov 15, 2022
1 parent eda0ad5 commit 501c8c1
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 60 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,6 @@ jobs:
- name: Run Dialyzer
run: mix dialyzer --halt-exit-status

gettext:
name: Missing translation keys check
runs-on: ubuntu-18.04
needs: build-and-cache
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- name: Restore Mix Deps Cache
uses: actions/cache@v2
id: deps-cache
with:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_12-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
- run: |
mix gettext.extract --merge | tee stdout.txt
! grep "Wrote " stdout.txt
working-directory: "apps/block_scout_web"
sobelow:
name: Sobelow security analysis
runs-on: ubuntu-18.04
Expand Down
111 changes: 77 additions & 34 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,91 @@
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image
name: Build and push to registry

on:
push:
branches: [master]
branches:
- master

env:
REGISTRY_NAME: altregistry
OTP_VERSION: '24.3.4.1'
ELIXIR_VERSION: '1.13.4'
ECR_REGISTRY: 305587085711.dkr.ecr.us-west-2.amazonaws.com
ECR_REPOSITORY: blockscout

jobs:
push_to_registry:
name: Push Docker image to Azure Container Registry
build-and-push-to-registry:
name: Push docker image to registry
runs-on: ubuntu-latest
env:
RELEASE_VERSION: 4.1.5

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Azure Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_NAME }}.azurecr.io
username: ${{ secrets.ALTREGISTRY_USERNAME }}
password: ${{ secrets.ALTREGISTRY_PASSWORD }}

- name: Get short hash
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c 1-8`" >> $GITHUB_ENV

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_NAME }}.azurecr.io/blockscout

- name: Build & Push Docker image
run: docker buildx build -t ${{ env.REGISTRY_NAME }}.azurecr.io/blockscout:latest -t ${{ env.REGISTRY_NAME }}.azurecr.io/blockscout:${{ env.SHORT_SHA }} -f ./docker/Dockerfile --push --platform=linux/amd64 .
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: docker-builder
uses: docker/setup-buildx-action@v2

- name: Log in to ECR
uses: docker/login-action@v2
with:
registry: ${{ env.ECR_REGISTRY }}
username: ${{ secrets.ECR_ACCESS_KEY_ID }}
password: ${{ secrets.ECR_ACCESS_KEY }}

- name: Cache Buildx
uses: actions/cache@v3
id: buildx-cache
with:
# https://github.com/actions/cache/blob/main/examples.md#elixir---mix
path: |
${{ github.workspace }}/deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}
tags: |
type=raw,value={{sha}}
type=raw,value={{branch}}-{{sha}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
id: docker_build
with:
context: .
file: ./docker/Dockerfile
push: true
builder: ${{ steps.docker-builder.outputs.name }}
cache-from: |
type=local,src=${{ github.workspace }}/deps
cache-to: |
type=local,dest=${{ github.workspace }}/deps
tags: ${{ steps.meta.outputs.tags }}
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_READ_API=false
API_PATH=
NETWORK_PATH=
DISABLE_WEBAPP=false
DISABLE_WRITE_API=false
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
WOBSERVER_ENABLED=false
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
DISABLE_BRIDGE_MARKET_CAP_UPDATER=false
CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=
SOCKET_ROOT=
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 501c8c1

Please sign in to comment.