Merge pull request #252 from sethforprivacy/github-ci #1
This file contains 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: "Update image and push to Github Packages and Docker Hub when Dockerfile is changed" | |
# Run this workflow every time a new commit pushed to your repository | |
on: | |
push: | |
paths-ignore: | |
- 'README.md' | |
jobs: | |
rebuild-container: | |
name: "Rebuild Container with the latest base image" | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1.6.0 | |
- | |
name: Login to GitHub Container Registry | |
uses: docker/login-action@v1.10.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v1.10.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Checkout repository" | |
uses: "actions/checkout@v2.3.4" | |
- | |
name: "Get Monero Release Tag" | |
id: get_tag | |
run: echo "::set-output name=tag::$(awk -F "=" '/MONERO_BRANCH=/ {print $2}' Dockerfile)" | |
- | |
name: Build and push to Docker Hub and Github Packages Docker Registry | |
id: docker_build | |
uses: docker/build-push-action@v2.7.0 | |
with: | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/xmrblocks:latest | |
ghcr.io/${{ github.repository_owner }}/xmrblocks:${{ steps.get_tag.outputs.tag }} | |
${{ secrets.DOCKER_USERNAME }}/xmrblocks:latest | |
${{ secrets.DOCKER_USERNAME }}/xmrblocks:${{ steps.get_tag.outputs.tag }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/xmrblocks:latest | |
cache-to: type=inline | |
- | |
name: Scan new image and output results | |
uses: Azure/container-scan@v0 | |
with: | |
image-name: ${{ secrets.DOCKER_USERNAME }}/xmrblocks:${{ steps.get_tag.outputs.tag }} | |
severity-threshold: HIGH | |
- | |
name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |