Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #39 from demokratie-live/feature/docker_hub
Browse files Browse the repository at this point in the history
move docker image to docker hub
  • Loading branch information
roschaefer authored Jun 17, 2021
2 parents bd26788 + 472a3a1 commit de44e89
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
name: Docker Image
name: bundestag.io-admin/ Build and Push Docker Image

on:
- push
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"

jobs:
build:
name: Build Docker
push:
runs-on: ubuntu-latest
environment: docker
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
submodules: true

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo dev)"
id: extract_branch

# - name: Extract branch name
# shell: bash
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# id: extract_branch

- name: Read package.json
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version

- name: Extract repository name
shell: bash
run: echo "##[set-output name=REPOSITORY_NAME;]$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")"
id: extract_repository

- uses: docker/build-push-action@v1
images: democracy/bundestag.io-admin
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: docker.pkg.github.com
repository: ${{ github.repository }}/${{ steps.extract_repository.outputs.REPOSITORY_NAME }}
tags: ${{ steps.package-version.outputs.version }}-${{ steps.extract_branch.outputs.branch }}
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit de44e89

Please sign in to comment.