Update cache #317
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: "Release" | |
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags | |
on: | |
push: | |
branches: | |
- 'ubuntu20-cache' | |
jobs: | |
env-prod: | |
runs-on: ubuntu-20.04 | |
steps: | |
################################################################ | |
# Git checkout | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
################################################################ | |
# Build | |
# The github.ref is, for example, refs/tags/dev @see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
# Generate variables like: | |
# SRS_TAG=dev | |
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable | |
- name: Generate varaiables | |
id: srs-vars | |
run: | | |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') | |
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV | |
outputs: | |
SRS_TAG: ${{ env.SRS_TAG }} | |
docker-prod: | |
runs-on: ubuntu-20.04 | |
needs: | |
- env-prod | |
steps: | |
################################################################ | |
- name: Covert output to env | |
run: | | |
SRS_TAG=${{ needs.env-prod.outputs.SRS_TAG }} | |
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV | |
################################################################ | |
# Git checkout | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Remove unnecessary files | |
run: | | |
df -h | |
echo "" | |
echo "After removed some unused files." | |
echo "" | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \ | |
/usr/local/share/powershell /usr/share/swift /usr/lib/jvm | |
df -h | |
# See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
################################################################ | |
# Docker | |
- name: Login docker hub | |
uses: docker/login-action@v2 | |
with: | |
username: "${{ secrets.DOCKER_USERNAME }}" | |
password: "${{ secrets.DOCKER_PASSWORD }}" | |
- name: Build and push to docker registry | |
run: | | |
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ | |
--output "type=image,push=true" \ | |
-t ossrs/srs:$SRS_TAG . | |
outputs: | |
SRS_DOCKER_PROD_DONE: ok | |
aliyun-prod: | |
name: for aliyun | |
runs-on: ubuntu-20.04 | |
needs: | |
- env-prod | |
- docker-prod | |
steps: | |
################################################################ | |
- name: Covert output to env | |
run: | | |
SRS_TAG=${{ needs.env-prod.outputs.SRS_TAG }} | |
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV | |
################################################################ | |
# Aliyun ACR | |
- name: Login aliyun hub | |
uses: docker/login-action@v2 | |
with: | |
registry: registry.cn-hangzhou.aliyuncs.com | |
username: "${{ secrets.ACR_USERNAME }}" | |
password: "${{ secrets.ACR_PASSWORD }}" | |
- name: Copy to Aliyun registry | |
uses: akhilerm/tag-push-action@v2.1.0 | |
with: | |
src: ossrs/srs:${{ env.SRS_TAG }} | |
dst: | | |
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_TAG }} | |
outputs: | |
SRS_ALIYUN_PROD_DONE: ok | |
done: | |
name: done | |
runs-on: ubuntu-20.04 | |
needs: | |
- docker-prod | |
- aliyun-prod | |
steps: | |
- run: echo 'All done' | |