Skip to content

Instantly share code, notes, and snippets.

@Aventhor
Created March 14, 2023 06:42
Show Gist options
  • Save Aventhor/f68dd0bf37e2e2eb55bf2ad3928eaf7e to your computer and use it in GitHub Desktop.
Save Aventhor/f68dd0bf37e2e2eb55bf2ad3928eaf7e to your computer and use it in GitHub Desktop.
Github Actions Example
name: Build
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build
run: docker build -t app ./app
- name: Tags
run: |
docker tag app name/my-app:${{ github.sha }}
docker tag app name/my-app:latest
docker tag app name/my-app:${GITHUB_REF#refs/tags/}
- name: Push
run: |
docker push name/my-app:${{ github.sha }}
docker push name/my-app:latest
docker push name/my-app:${GITHUB_REF#refs/tags/}
name: Deploy
on:
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Deployment
uses: wshihadeh/docker-deployment-action@master
with:
remote_docker_host: ${{ secrets.HOST }}
ssh_private_key: ${{ secrets.PRIVATE_KEY }}
ssh_public_key: ${{ secrets.PUBLIC_KEY }}
deployment_mode: docker-compose
deploy_path: ~/deploy
stack_file_name: docker-compose.yml
pull_images_first: true
args: up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment