Skip to content

Commit

Permalink
use reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mszulik committed Mar 14, 2024
1 parent 52a70a1 commit bf81494
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 60 deletions.
39 changes: 6 additions & 33 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,12 @@ name: Docker Image CI

on:
release:
types: [published]
types: [ published ]

jobs:
build-push-docker-image:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout code
uses: actions/checkout@v4

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
cybexwebdev/connector
flavor: |
latest=auto
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
file: ./docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
name: Build, test and push docker image
uses: cybex-gmbh/github-workflows/.github/workflows/docker-build-push.yml@main
with:
DOCKER_REPOSITORY: cybexwebdev/connector
secrets: inherit
39 changes: 12 additions & 27 deletions .github/workflows/pullpreview.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
name: PullPreview

on:
pull_request:
types: [ labeled, unlabeled, synchronize, closed, reopened ]

jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
deploy-staging-environment:
permissions:
contents: read # to fetch code (actions/checkout)
deployments: write # to delete deployments
pull-requests: write # to remove labels
statuses: write # to create commit status
steps:
- uses: actions/checkout@v4

- name: Generate .env file
env:
SECRETS_PULLPREVIEW_CONNECTOR_USER_PUBLICKEY: ${{ secrets.PULLPREVIEW_CONNECTOR_USER_PUBLICKEY }}
SECRETS_PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH: ${{ secrets.PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH }}
run: |
cp .env.example .env
echo "APP_ENV=production" >> .env
echo "APP_DEBUG=false" >> .env
echo "PULLPREVIEW_CONNECTOR_USER_PUBLICKEY=$SECRETS_PULLPREVIEW_CONNECTOR_USER_PUBLICKEY" >> .env
echo "PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH=$SECRETS_PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH" >> .env
name: Deploy PullPreview staging environment
uses: cybex-gmbh/github-workflows/.github/workflows/pullpreview.yml@feature/add-workflows
with:
PULLPREVIEW_ADMINS: jheusinger, gael-connan-cybex, holyfabi, lupinitylabs, mszulik
secrets:
ENV_VARS: |
PULLPREVIEW_CONNECTOR_USER_PUBLICKEY="${{ secrets.PULLPREVIEW_CONNECTOR_USER_PUBLICKEY }}"
PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH="${{ secrets.PULLPREVIEW_CONNECTOR_PROTECTOR_AUTH_TOKEN_HASH }}"
PULLPREVIEW_AWS_ACCESS_KEY_ID: ${{ secrets.PULLPREVIEW_AWS_ACCESS_KEY_ID }}
PULLPREVIEW_AWS_SECRET_ACCESS_KEY: ${{ secrets.PULLPREVIEW_AWS_SECRET_ACCESS_KEY }}

- uses: pullpreview/action@v5
with:
admins: jheusinger, gael-connan-cybex, holyfabi, lupinitylabs, mszulik
cidrs: "0.0.0.0/0"
compose_files: docker-compose.pullpreview.yml
default_port: 80
instance_type: nano
ports: 80, 443
env:
AWS_ACCESS_KEY_ID: "${{ secrets.PULLPREVIEW_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.PULLPREVIEW_AWS_SECRET_ACCESS_KEY }}"
AWS_REGION: "eu-central-1"

0 comments on commit bf81494

Please sign in to comment.