Skip to content

Commit

Permalink
Add workflow for image build
Browse files Browse the repository at this point in the history
  • Loading branch information
ptichoid committed Oct 23, 2024
1 parent 2180a67 commit f40fae4
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker-build-push-on-tag-or-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker Image Build on tag or release

on:
push:
tags:
- '*'
release:
types: [published]

env:
ORG: opentelekomcloud
PROJECT: eyes_on_docs

jobs:
push_if_tag:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
"${{ secrets.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}"
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
build-args: |
BASE_URL=${{ secrets.BASE_URL }}
AUTH_TOKEN=${{ secrets.AUTH_TOKEN }}
95 changes: 95 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Docker Image Build

on:
pull_request:
types:
- opened
- closed
- edited
- reopened
- synchronize

env:
ORG: opentelekomcloud
PROJECT: eyes_on_docs

jobs:

build:
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
"${{ secrets.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}"
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: false
build-args: |
BASE_URL=${{ secrets.BASE_URL }}
AUTH_TOKEN=${{ secrets.AUTH_TOKEN }}
push_if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
"${{ secrets.REGISTRY }}/${{ env.ORG }}/${{ env.PROJECT }}"
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
build-args: |
BASE_URL=${{ secrets.BASE_URL }}
AUTH_TOKEN=${{ secrets.AUTH_TOKEN }}

0 comments on commit f40fae4

Please sign in to comment.