CD #9
This file contains hidden or 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: CD | |
on: | |
workflow_dispatch: | |
inputs: | |
Docker: | |
description: 'Build and Push to Docker Hub' | |
default: false | |
type: boolean | |
Snap: | |
description: 'Build snap package' | |
default: false | |
type: boolean | |
Snapcraft: | |
description: 'Push to Snapcraft' | |
default: false | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
if: ${{ github.event.inputs.Docker == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
if: ${{ github.event.inputs.Docker == 'true' }} | |
run: | | |
docker build -t lifailon/lazyjournal:latest . | |
docker push lifailon/lazyjournal:latest | |
- name: Install Go | |
if: ${{ github.event.inputs.Docker != 'true' }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23 | |
- name: Install snapcraft and build snap package | |
if: ${{ github.event.inputs.Snap == 'true' || github.event.inputs.Snapcraft == 'true' }} | |
run: | | |
sudo apt update | |
sudo apt install -y snapd | |
snap version | |
sudo snap install snapcraft --classic | |
snapcraft version | |
version=$(go run main.go -v) | |
sed -i "s/0.7.7/$version/g" snapcraft.yaml | |
snapcraft --destructive-mode | |
sudo snap install *.snap --dangerous --classic | |
snap remove lazyjournal | |
- name: Login and push to Snapcraft | |
if: ${{ github.event.inputs.Snapcraft == 'true' }} | |
run: | | |
# snapcraft export-login --snaps lazyjournal snap-login.txt | |
export SNAPCRAFT_STORE_CREDENTIALS="${{ secrets.SNAPCRAFT_SECRET }}" | |
snapcraft push *.snap | |
- name: Upload snap package | |
if: ${{ github.event.inputs.Snap == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: snap-package | |
path: lazyjournal*.snap |