Skip to content

CI/CD with Docker

CI/CD with Docker #162

Workflow file for this run

name: CI/CD with Docker
on:
push:
branches: [ main ]
schedule:
- cron: '0 0 */3 * *'
env:
TAG_NAME: ${{ github.sha }}
jobs:
publish:
name: Publish to Github Pages
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build the Docker image
# run: docker build . --file Dockerfile --tag lojban:latest
run: docker build . --file Dockerfile --tag lojban:latest --cache-from=type=local,src=/tmp/.buildx-cache
# run: docker build . --file Dockerfile --tag lojban:${{ env.TAG_NAME }}
- name: Install zip
uses: montudor/action-zip@v1
- name: Run Docker container
uses: kohlerdominik/docker-run-action@v1
with:
run: yarn build && yarn zip
image: lojban:latest
# environment: |
# THIS_REPO_NAME=${{ secrets.THIS_REPO_NAME }}
volumes: |
${{ github.workspace }}/src:/app/src
${{ github.workspace }}/dist:/app/dist
${{ github.workspace }}/assets:/app/assets
${{ github.workspace }}/tools:/app/tools
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: output-files
path: ${{ github.workspace }}/dist/artifact.zip
- name: Cleanup
uses: AutoModality/action-clean@v1
- name: Checkout branch
uses: actions/checkout@v2
with:
ref: gh-pages
- name: Clean up the current branch
run: |
git rm -rf . 2>/dev/null
git clean -df
rm -rf ./*
- name: Download to branch
uses: actions/download-artifact@v3
with:
name: output-files
path: ${{ github.workspace }}/artifact.zip
- name: Unzip artifact
run: chmod u+rw artifact.zip/artifact.zip && unzip artifact.zip/artifact.zip && rm -rf artifact.zip && mv ./dist/* . && rm -rf ./dist
# - name: Unzip artifact
# run: unzip artifact.zip && rm artifact.zip
- name: Commit & push to branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Deploy from `main` branch
# Optional. Local and remote branch name where commit is going to be pushed
# to. Defaults to the current branch.
# You might need to set `create_branch: true` if the branch does not exist.
branch: gh-pages
# Optional. Options used by `git-push`.
# See https://git-scm.com/docs/git-push#_options
push_options: '--force'
# Optional. Create given branch name in local and remote repository.
create_branch: true