mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2025-01-31 13:02:43 -05:00
chore(docker): improve docker build workflow
This commit is contained in:
parent
dcaa5eccf9
commit
8eff8847ea
3 changed files with 69 additions and 44 deletions
26
.github/workflows/cd.yml
vendored
26
.github/workflows/cd.yml
vendored
|
@ -64,29 +64,3 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: publish
|
command: publish
|
||||||
args: --locked --token ${{ secrets.CARGO_TOKEN }}
|
args: --locked --token ${{ secrets.CARGO_TOKEN }}
|
||||||
|
|
||||||
publish-docker:
|
|
||||||
name: Publish the Docker image
|
|
||||||
needs: publish-github
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
- name: Set the release version
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
|
|
||||||
- name: Build
|
|
||||||
run: docker build -t rustypaste .
|
|
||||||
- name: Tag
|
|
||||||
run: |
|
|
||||||
docker tag rustypaste orhunp/rustypaste:${{ env.RELEASE_VERSION }}
|
|
||||||
docker tag rustypaste docker.pkg.github.com/orhun/rustypaste/rustypaste:${{ env.RELEASE_VERSION }}
|
|
||||||
- name: Login (Docker Hub)
|
|
||||||
run: echo ${{ secrets.DOCKER_TOKEN }} |
|
|
||||||
docker login -u orhunp --password-stdin
|
|
||||||
- name: Push (Docker Hub)
|
|
||||||
run: docker push orhunp/rustypaste:${{ env.RELEASE_VERSION }}
|
|
||||||
- name: Login (Package Registry)
|
|
||||||
run: echo ${{ secrets.GITHUB_TOKEN }} |
|
|
||||||
docker login -u orhun docker.pkg.github.com --password-stdin
|
|
||||||
- name: Push (Package Registry)
|
|
||||||
run: docker push docker.pkg.github.com/orhun/rustypaste/rustypaste:${{ env.RELEASE_VERSION }}
|
|
||||||
|
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -7,6 +7,8 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * 0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
|
|
85
.github/workflows/docker.yml
vendored
85
.github/workflows/docker.yml
vendored
|
@ -4,27 +4,76 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * 0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
name: Docker
|
name: Docker Build and Push
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v2
|
||||||
- name: Build
|
|
||||||
run: docker build -t rustypaste .
|
- name: Docker meta
|
||||||
- name: Tag
|
id: meta
|
||||||
run: |
|
uses: docker/metadata-action@v3
|
||||||
docker tag rustypaste orhunp/rustypaste:latest
|
with:
|
||||||
docker tag rustypaste docker.pkg.github.com/orhun/rustypaste/rustypaste:latest
|
images: |
|
||||||
- name: Login (Docker Hub)
|
orhunp/rustypaste
|
||||||
run: echo ${{ secrets.DOCKER_TOKEN }} |
|
ghcr.io/${{ github.repository_owner }}/rustypaste/rustypaste
|
||||||
docker login -u orhunp --password-stdin
|
tags: |
|
||||||
- name: Push (Docker Hub)
|
type=schedule
|
||||||
run: docker push orhunp/rustypaste:latest
|
type=ref,event=branch
|
||||||
- name: Login (Package Registry)
|
type=ref,event=pr
|
||||||
run: echo ${{ secrets.GITHUB_TOKEN }} |
|
type=sha
|
||||||
docker login -u orhun docker.pkg.github.com --password-stdin
|
type=raw,value=latest
|
||||||
- name: Push (Package Registry)
|
type=semver,pattern={{version}}
|
||||||
run: docker push docker.pkg.github.com/orhun/rustypaste/rustypaste:latest
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- 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: Login to Docker Hub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: orhunp
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GHCR
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
Loading…
Reference in a new issue