muse/.github/workflows/pr.yml

92 lines
3.1 KiB
YAML
Raw Normal View History

2021-12-14 02:25:32 +01:00
name: PR Workflow
2021-12-18 19:12:38 +01:00
on: pull_request_target
2021-12-14 02:25:32 +01:00
jobs:
release-snapshot:
2021-12-14 02:25:32 +01:00
name: Release snapshot
strategy:
matrix:
runner-platform:
- ubuntu-latest
- self-hosted
include:
- runner-platform: ubuntu-latest
build-arch: linux/amd64
tagged-platform: amd64
- runner-platform: self-hosted
build-arch: linux/arm64
tagged-platform: arm64
runs-on: ${{ matrix.runner-platform }}
2021-12-14 02:25:32 +01:00
steps:
- name: Set up Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
2022-03-26 22:51:34 +01:00
# AWS data transfer is pricy
if: ${{ matrix.runner-platform != 'self-hosted' }}
2021-12-14 02:25:32 +01:00
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
2022-01-26 02:15:14 +01:00
key: ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }}-${{ github.event.pull_request.head.sha }}
2021-12-14 02:25:32 +01:00
restore-keys: |
${{ runner.os }}-buildx-prs-${{ matrix.build-arch }}
2021-12-14 02:25:32 +01:00
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2022-01-26 02:15:14 +01:00
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
2022-03-26 22:51:34 +01:00
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
2021-12-14 02:25:32 +01:00
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
2022-01-26 02:31:56 +01:00
context: .
2021-12-14 02:25:32 +01:00
push: true
tags: codetheweb/muse:${{ github.event.pull_request.head.sha }}-${{ matrix.tagged-platform }}
2021-12-14 02:25:32 +01:00
cache-from: type=local,src=/tmp/.buildx-cache
2022-02-12 03:13:17 +01:00
cache-to: type=local,dest=/tmp/.buildx-cache,mode=min
platforms: ${{ matrix.build-arch }}
2022-03-26 22:51:34 +01:00
build-args: |
COMMIT_HASH=${{ github.sha }}
BUILD_DATE=${{ steps.current-time.outputs.time }}
combine-and-comment:
name: Combine platform tags and leave comment
runs-on: ubuntu-latest
needs: release-snapshot
steps:
- name: Set up Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Combine tags
run: docker buildx imagetools create -t 'codetheweb/muse:pr-${{ github.event.number }}' -t 'codetheweb/muse:${{ github.event.pull_request.head.sha }}' 'codetheweb/muse:${{ github.event.pull_request.head.sha }}-arm64' 'codetheweb/muse:${{ github.event.pull_request.head.sha }}-amd64'
2021-12-14 02:25:32 +01:00
- name: Create comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: "pr-release"
message: |
#### :package: A new release has been made for this pull request.
To play around with this PR, pull `codetheweb/muse:pr-${{ github.event.number }}` or `codetheweb/muse:${{ github.event.pull_request.head.sha }}`.
2021-12-14 02:25:32 +01:00
Images are available for x86_64 and ARM64.
2021-12-14 02:25:32 +01:00
> Latest commit: ${{ github.event.pull_request.head.sha }}