Created
March 14, 2023 06:42
-
-
Save Aventhor/f68dd0bf37e2e2eb55bf2ad3928eaf7e to your computer and use it in GitHub Desktop.
Github Actions Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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