Skip to content

Commit

Permalink
Use GitHub docker registry and remove deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
3j14 committed Oct 13, 2021
1 parent 589272f commit 34ed7a6
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Build and Deploy

on:
workflow_run:
workflows: ["Test"]
branches: [main]
types:
- completed
release:
# The tag will be available at ${{ env.GITHUB_REF }}
types: [published]

jobs:
build:
Expand All @@ -21,51 +19,54 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Registry
uses: docker/login-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: reg.desk-lab.de
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD}}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push doku-static
- name: Extract metadata (tags, labels) for Docker (static)
id: meta_static
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
# In the code below, we enable the 'dev' or 'latest' tag depending
# on the release type.
tags: |
type=semver,pattern={{version}}
type=raw,value=dev,enable=${{ github.event.release.prerelease }}
flavor: |
prefix=static
latest=${{ !github.event.release.prerelease }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
# In the code below, we enable the 'dev' or 'latest' tag depending
# on the release type.
tags: |
type=semver,pattern={{version}}
type=raw,value=dev,enable=${{ github.event.release.prerelease }}
flavor: |
latest=${{ !github.event.release.prerelease }}
- name: Build and push
uses: docker/build-push-action@v2
with:
file: 'doku/static/Dockerfile'
context: 'doku/static'
push: true
tags: |
reg.desk-lab.de/doku-static:${{ github.sha }}
reg.desk-lab.de/doku-static
tags: ${{ steps.meta_static.outputs.tags }}
labels: ${{ steps.meta_static.outputs.labels }}

- name: Build and push doku
uses: docker/build-push-action@v2
with:
file: './Dockerfile'
context: '.'
push: true
tags: |
reg.desk-lab.de/doku:${{ github.sha }}
reg.desk-lab.de/doku
deploy:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Ansible
run: sudo apt-get update && sudo apt-get install -y ansible

- name: Run Ansible Playbook
working-directory: './.github/ansible'
env:
REMOTE_PROJECT_SRC: ${{ secrets.DEPLOY_PROJECT_SRC }}
ANSIBLE_REMOTE_USER: ${{ secrets.DEPLOY_USER }}
SSH_PRIVATE_KEY : ${{ secrets.DEPLOY_SSH_KEY }}
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
ANSIBLE_HOST_KEY_CHECKING: 'False'
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "$SSH_PRIVATE_KEY"
ansible-playbook --inventory ${{ secrets.DEPLOY_HOST }}, deploy.yml
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 34ed7a6

Please sign in to comment.