Skip to content

Commit

Permalink
Build please
Browse files Browse the repository at this point in the history
  • Loading branch information
cycle-five committed Feb 14, 2024
1 parent 4470814 commit 4828081
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 95 deletions.
78 changes: 13 additions & 65 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,21 @@
name: Docker Workflow

on:
workflow_dispatch:
push:
branches:
- 'master'
tags: ['v*.*.*']
pull_request:
branches:
- 'master'
workflow_call:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
steps:
- name: Repository Checkout
uses: actions/checkout@v4
-
name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres
-
uses: ikalnytskyi/action-setup-postgres@v4
with:
username: postgres
password: mysecretpassword
database: postgres
port: 5432
id: postgres
-
name: Cache
uses: Swatinem/rust-cache@v2
-
name: Migrate database
env:
DATABASE_URL: ${{ steps.postgres.outputs.connection-uri }}
run: |
sqlx database create
sqlx migrate run --source migrations/
cargo sqlx prepare --workspace
-
name: Build Docker Image
env:
DATABASE_URL: ${{ steps.postgres.outputs.connection-uri }}
run: docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
push:
name: Build & Push Docker Image
runs-on: ubuntu-latest
Expand All @@ -57,47 +27,25 @@ jobs:
- name: Repository Checkout
uses: actions/checkout@v4
-
name: Cache
uses: Swatinem/rust-cache@v2
-
name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres
-
uses: ikalnytskyi/action-setup-postgres@v4
name: Extract Git Metadata
id: meta
uses: docker/metadata-action@v5
with:
username: postgres
password: mysecretpassword
database: postgres
port: 5432
id: postgres
#images: cyclefive/cracktunes
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Registry Login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract Git Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Migrate database
env:
DATABASE_URL: ${{ steps.postgres.outputs.connection-uri }}
PG_USER: postgres
PG_PASSWORD: mysecretpassword
run: |
sqlx database create
sqlx migrate run --source migrations/
cargo sqlx prepare --workspace
-
name: Build & Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
# push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
53 changes: 23 additions & 30 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@
name: Dockerhub

on:
# push:
# tags: ['v*.*.*']
# branches: [master]
workflow_dispatch:
push:
branches:
- 'master'
tags: ['v*.*.*']
pull_request:
#branches:
# - 'master'
workflow_call:

env:
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: cyclefive/cracktunes

jobs:
push:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
#if: github.event_name == 'push' || (github.event_name == 'workflow_call' && github.event.inputs.trigger == 'build')
#if: github.event_name == 'push' || (github.event_name == 'workflow_call' && github.event.inputs.trigger == 'build')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
-
name: Repository Checkout
Expand All @@ -39,32 +48,16 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Cache
uses: Swatinem/rust-cache@v2
-
name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres
-
uses: ikalnytskyi/action-setup-postgres@v4
name: Extract Git Metadata
id: meta
uses: docker/metadata-action@v5
with:
username: postgres
password: mysecretpassword
database: postgres
port: 5432
id: postgres
-
name: Migrate database
env:
DATABASE_URL: ${{ steps.postgres.outputs.connection-uri }}
PG_USER: postgres
PG_PASSWORD: mysecretpassword
run: |
sqlx database create
sqlx migrate run --source migrations/
cargo sqlx prepare --workspace
images: cyclefive/cracktunes
-
name: Build and push
name: Build & Push Docker Image
uses: docker/build-push-action@v5
with:
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
tags: ${{ env.IMAGE_NAME }}
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 4828081

Please sign in to comment.