Update docker/metadata-action action to v5.6.1 #585
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: Publish Docker image | |
on: | |
release: | |
types: [published] | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
paths-ignore: | |
- "sas" | |
jobs: | |
push_to_registries: | |
name: Push Docker image to docker hub | |
runs-on: ubuntu-22.04 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: 'eu-west-1' | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Fetch data | |
if: github.event_name != 'pull_request' | |
run: git clone --depth 1 --branch 2023.0 https://gitlab-ci-token:${{ secrets.GL_TOKEN }}@gitlab.com/${{ secrets.GL_ORG2 }} | |
- name: Create fake data | |
if: github.event_name == 'pull_request' | |
run: | | |
mkdir -p tmongrdata | |
touch tmongrdata/fag.rds | |
- name: R setup | |
uses: r-lib/actions/setup-r@v2.11.0 | |
- name: Build package | |
run: R CMD build . | |
- name: Lint Dockerfile | |
uses: hadolint/hadolint-action@v3.1.0 | |
with: | |
dockerfile: "Dockerfile" | |
- name: Prepare | |
id: docker_meta | |
uses: docker/metadata-action@v5.6.0 | |
with: | |
images: hnskde/tmongr | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.7.1 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3.3.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push to Docker Hub | |
uses: docker/build-push-action@v6.9.0 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Set release variables | |
if: github.event_name == 'release' | |
run: | | |
echo "S3Key='prod-tmongr_dockerrun.json'" >> $GITHUB_ENV | |
echo "env_name=prod-tabellverk" >> $GITHUB_ENV | |
echo "version_label=${GITHUB_REF:10}" >> $GITHUB_ENV | |
echo "descr='Release tag deploy'" >> $GITHUB_ENV | |
- name: Set QA variables | |
if: github.event_name == 'push' | |
run: | | |
echo "S3Key='qa-tmongr_dockerrun.json'" >> $GITHUB_ENV | |
echo "env_name=qa-tabellverk" >> $GITHUB_ENV | |
echo "version_label=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
echo "descr='main commits deploy'" >> $GITHUB_ENV | |
- name: Update elasticbeanstalk | |
if: github.event_name != 'pull_request' | |
run: | | |
aws elasticbeanstalk create-application-version --application-name tabellverk --source-bundle S3Bucket="elasticbeanstalk-eu-west-1-247247832514",S3Key=${{ env.S3Key }} --version-label ${{ env.version_label }} --description ${{ env.descr }} | |
aws elasticbeanstalk update-environment --environment-name ${{ env.env_name }} --version-label ${{ env.version_label }} |