dnstp/.github/workflows/build.yml

111 lines
2.8 KiB
YAML
Raw Permalink Normal View History

2024-01-28 19:37:35 +00:00
name: Build Binaries
on:
# Runs on pushes targeting the default branch
push:
2024-01-30 22:11:04 +00:00
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2024-01-28 19:37:35 +00:00
concurrency:
2024-01-30 22:11:04 +00:00
group: "pages"
cancel-in-progress: false
2024-01-28 19:37:35 +00:00
jobs:
# Build job
build:
2024-01-30 22:40:56 +00:00
name: Build & Test
2024-01-28 19:37:35 +00:00
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
2024-01-28 19:40:37 +00:00
with:
toolchain: stable
2024-01-28 19:37:35 +00:00
- name: Cargo Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Cargo Test
uses: actions-rs/cargo@v1
with:
2024-01-30 21:58:09 +00:00
command: test
doc:
2024-01-30 22:40:56 +00:00
name: Build Documentation
2024-01-30 22:11:04 +00:00
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
2024-01-30 21:58:09 +00:00
runs-on: ubuntu-latest
needs: [ build ] # for ignoring bad builds
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout
2024-01-30 22:11:04 +00:00
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
2024-01-30 21:58:09 +00:00
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build Docs
run: cargo doc --no-deps --document-private-items
2024-02-01 08:36:10 +00:00
- name: Add redirect
run: echo '<meta http-equiv="refresh" content="0;url=dnstplib/index.html">' > target/doc/index.html
2024-02-01 08:36:10 +00:00
- name: Remove lock file
run: rm target/doc/.lock
2024-01-30 22:11:04 +00:00
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
2024-01-30 21:58:09 +00:00
with:
2024-01-30 22:11:04 +00:00
# Upload entire repository
path: './target/doc'
2024-01-30 22:40:56 +00:00
deploy:
name: Deploy Documentation
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
2024-01-30 22:41:27 +00:00
needs: doc
2024-01-30 22:40:56 +00:00
steps:
2024-01-30 22:11:04 +00:00
- name: Deploy to GitHub Pages
id: deployment
2024-02-07 19:04:04 +00:00
uses: actions/deploy-pages@v4
package:
runs-on: ubuntu-latest
name: Package Container
needs: [ build ] # for ignoring bad builds
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Container
uses: docker/build-push-action@v2
with:
push: true
tags: sarsoo/dnstp:latest