Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init GHA #1

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build-deploy-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: build-deploy-pr
on:
pull_request:
jobs:
deploy-images:
runs-on: ubuntu-latest
env:
registry: ghcr.io
username: degauss-org
repository: daymet_chicago
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: create latest tag variable
run: |
container="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:latest"
echo "container=${container}" >> $GITHUB_ENV
- name: create pull request tag variable based on name of associated branch
if: github.event_name == 'pull_request'
run: |
versioned="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${GITHUB_HEAD_REF}"
echo "versioned=${versioned}" >> $GITHUB_ENV
- name: build container
run: |
docker build -t ${{ env.container }} .
- name: test run container
run: |
docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} loyalty_degauss.csv
- name: login to ghcr
uses: docker/login-action@v1
with:
registry: ${{ env.registry }}
username: ${{ env.username }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: deploy pull request container
run: |
docker tag ${{ env.container }} ${{ env.versioned }}
docker push ${{ env.versioned }}
42 changes: 42 additions & 0 deletions .github/workflows/build-deploy-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build-deploy-release
on:
release:
types: [published]
jobs:
deploy-images:
runs-on: ubuntu-latest
env:
registry: ghcr.io
username: degauss-org
repository: daymet_chicago
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: create latest tag variable
run: |
container="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:latest"
echo "container=${container}" >> $GITHUB_ENV
- name: create release tag variable
if: github.event_name == 'release'
run: |
versioned="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${GITHUB_REF##*/}"
echo "versioned=${versioned}" >> $GITHUB_ENV
- name: build container
run: |
docker build -t ${{ env.container }} .
- name: test container
run: |
docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} loyalty_degauss.csv
- name: login to ghcr
uses: docker/login-action@v1
with:
registry: ${{ env.registry }}
username: ${{ env.username }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: deploy release (and latest) container
run: |
docker tag ${{ env.container }} ${{ env.versioned }}
docker push ${{ env.versioned }}
docker push ${{ env.container }}
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.PHONY: build test shell clean
build:
docker build -t daymet_chicago .
test:
docker run --rm -v "${PWD}":/tmp daymet_chicago loyalty_degauss.csv
shell:
docker run --rm -it --entrypoint=/bin/bash -v "${PWD}":/tmp daymet_chicago
clean:
docker system prune -f
.PHONY: build test shell clean

build:
docker build -t daymet_chicago .

test:
docker run --rm -v "${PWD}/test":/tmp daymet_chicago loyalty_degauss.csv

shell:
docker run --rm -it --entrypoint=/bin/bash -v "${PWD}":/tmp daymet_chicago

clean:
docker system prune -f
6 changes: 3 additions & 3 deletions entrypoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ import_data <- function(.csv_filename = opt$filename, .min_lon = min_lon, .max_l
return(out)
}

# Creating function to load the Daymet NetCDF data
# Create function to load the Daymet NetCDF data
daymet_load <- function() {
# Loading the NetCDF files downloaded from Daymet as a SpatRaster raster stack
netcdf_list <- list.files(pattern = "_ncss.nc$")
netcdf_list <- list.files(path = "/app", pattern = "_ncss.nc$")
# Initializing a time dictionary
time_dict <- tibble(number = 1:365)
for (i in 1:length(netcdf_list)) {
Expand All @@ -154,7 +154,7 @@ daymet_load <- function() {
layer_names <- as.character(1:365)
layer_names <- paste0(dm_var, "_", layer_names, "_", yr)
# Loading the Daymet data
daymet_load <- rast(netcdf_list[i])
daymet_load <- rast(paste0("/app/", netcdf_list[i]))
names(daymet_load) <- layer_names
# Creating a dictionary to link numbers 1–365 to a date in a year (time dictionary)
origin <- as_date(paste0(yr, "-01-01")) - 1 # Numbers count days since origin
Expand Down
Loading