Build-and-Push #34
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: Build-and-Push | |
on: | |
schedule: | |
- cron: '0 0 1 * *' # monthly | |
workflow_dispatch: | |
jobs: | |
Build-and-Push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# - name: Set up QEMU | |
# uses: docker/setup-qemu-action@v2 | |
- 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: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Tag value | |
id: generate_tag_value | |
run: | | |
echo '::echo::on' | |
echo ::set-output name=image_tag::$(date +"%F")-$(git rev-parse --short HEAD) | |
- name: Build Docker Image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
labels: | | |
org.label-schema.vcs-ref=${{ github.sha }} | |
org.label-schema.vcs-url=https://github.com/${{ github.repository }} | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ steps.generate_tag_value.outputs.image_tag }} | |
ghcr.io/${{ github.repository }}:latest | |
${{ secrets.DOCKERHUB_USERNAME }}/tree-planter:${{ steps.generate_tag_value.outputs.image_tag }} | |
${{ secrets.DOCKERHUB_USERNAME }}/tree-planter:latest | |
- name: Generate Release Body | |
env: | |
RELEASE_BODY_FILE: "release-body.md" | |
run: | | |
echo "## Components" > ${RELEASE_BODY_FILE} | |
echo "" >> ${RELEASE_BODY_FILE} | |
echo "This release includes the following:" >> ${RELEASE_BODY_FILE} | |
echo "" >> ${RELEASE_BODY_FILE} | |
echo "### Source image" >> ${RELEASE_BODY_FILE} | |
echo "" >> ${RELEASE_BODY_FILE} | |
echo "- $(grep ^FROM ./Dockerfile |cut -d ' ' -f2)" >> ${RELEASE_BODY_FILE} | |
echo "- OS updates" >> ${RELEASE_BODY_FILE} | |
echo "- Updates via Dependabot PRs" >> ${RELEASE_BODY_FILE} | |
echo "- Updates via any other merged PRs" >> ${RELEASE_BODY_FILE} | |
echo "" >> ${RELEASE_BODY_FILE} | |
- name: Tag Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.generate_tag_value.outputs.image_tag }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: false | |
prerelease: false | |
bodyFile: "release-body.md" | |
generateReleaseNotes: true |