Push Image Workflow #54
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: Push Image Workflow | |
on: | |
push: | |
tags: | |
- '*' | |
branches: | |
- 'release-*' | |
- '*-release' | |
- 'release/*' | |
- 'master' | |
schedule: | |
- cron: '0 0 * * 0' # This runs the workflow every Sunday at midnight UTC | |
jobs: | |
build-and-push-images: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@main | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Fetch latest tag | |
id: fetch-latest-tag | |
run: | | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "tag=$latest_tag" >> $GITHUB_ENV | |
- name: Set PUSH value | |
id: set-push | |
run: | | |
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" || "${{ github.ref }}" == "refs/heads/master" || "${{ github.event_name }}" == "schedule" ]]; then | |
echo "PUSH=true" >> $GITHUB_ENV | |
else | |
echo "PUSH=false" >> $GITHUB_ENV | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@master | |
- name: Login to Docker Hub | |
uses: docker/login-action@master | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to Github Packages | |
uses: docker/login-action@master | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@master | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: ./Dockerfile | |
push: ${{ env.PUSH }} | |
tags: | | |
jvrck/bbripper:latest | |
jvrck/bbripper:${{ env.tag }} | |
ghcr.io/jvrck/bbripper:latest | |
ghcr.io/jvrck/bbripper:${{ env.tag }} | |
build-and-push-awscli-images: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@main | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Fetch latest tag | |
id: fetch-latest-tag | |
run: | | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "tag=$latest_tag" >> $GITHUB_ENV | |
- name: Set PUSH value | |
id: set-push | |
run: | | |
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" || "${{ github.ref }}" == "refs/heads/master" || "${{ github.event_name }}" == "schedule" ]]; then | |
echo "PUSH=true" >> $GITHUB_ENV | |
else | |
echo "PUSH=false" >> $GITHUB_ENV | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@master | |
- name: Login to Docker Hub | |
uses: docker/login-action@master | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to Github Packages | |
uses: docker/login-action@master | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker with AWS | |
uses: docker/build-push-action@master | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: ./Dockerfile | |
build-args: AWSCLI=TRUE | |
push: ${{ env.PUSH }} | |
tags: | | |
jvrck/bbripper:latest-aws | |
jvrck/bbripper:${{ env.tag }}-aws | |
ghcr.io/jvrck/bbripper:latest-aws | |
ghcr.io/jvrck/bbripper:${{ env.tag }}-aws |