Update from https://github.com/internetofwater/geoconnex.us/commit/62… #162
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: pids.geoconnex.us build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "dev" | |
- "main" | |
paths: | |
- "namespaces/**" | |
jobs: | |
yourls-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Clone geoconnex.us | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh repo clone internetofwater/geoconnex.us | |
- name: Generate sitemap | |
uses: cgs-earth/[email protected] | |
with: | |
namespace_dir: ${{ github.workspace }}/namespaces | |
mysql-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Generate YOURLS Database | |
uses: cgs-earth/[email protected] | |
with: | |
namespace_dir: ${{ github.workspace }}/namespaces | |
cache-build: | |
runs-on: ubuntu-latest | |
needs: [containers-build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache Yourls MySQL | |
uses: actions/download-artifact@v3 | |
with: | |
name: yourls | |
path: build/yourls-mysql | |
- name: Cache Yourls Sitemap | |
uses: actions/download-artifact@v3 | |
with: | |
name: sitemap | |
path: build/yourls | |
- name: Commit and Push Changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "Update cached files" | |
default_author: "github_actions" | |
containers-build: | |
runs-on: ubuntu-latest | |
needs: [yourls-build, mysql-build] | |
permissions: | |
packages: write | |
contents: read | |
strategy: | |
matrix: | |
image: | |
- yourls | |
- yourls-mysql | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker YOURLS Meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository_owner }}/${{ matrix.image }} | |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=pep440,pattern={{version}} | |
- name: Cache Yourls MySQL | |
uses: actions/download-artifact@v3 | |
with: | |
name: yourls | |
path: build/yourls-mysql | |
- name: Cache Yourls Sitemap | |
uses: actions/download-artifact@v3 | |
with: | |
name: sitemap | |
path: build/yourls | |
- name: Unzip Sitemap | |
working-directory: ./build/yourls | |
run: unzip -o sitemap -d sitemap | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./build/${{ matrix.image }} | |
file: ./build/${{ matrix.image }}/Dockerfile | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64, linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-build-gcp: | |
runs-on: ubuntu-latest | |
needs: [mysql-build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: "${{ secrets.GCP_CREDENTIALS_JSON }}" | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Cache Yourls MySQL | |
uses: actions/download-artifact@v3 | |
with: | |
name: yourls | |
path: backup | |
- name: Upload backup to GCP Bucket | |
id: upload-files | |
uses: google-github-actions/upload-cloud-storage@v0 | |
with: | |
path: backup | |
destination: yourls-data | |
gzip: false | |
parent: false | |
headers: |- | |
content-type: application/x-gzip | |
- name: Push to mysql | |
run: |- | |
gcloud sql import sql yourls-mysql-8 gs://yourls-data/yourls.sql.gz \ | |
--database=yourls \ | |
--project=${{ secrets.GCP_PROJECT_ID }} | |
cache-build-ref: | |
runs-on: ubuntu-latest | |
needs: [yourls-build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache Yourls Sitemap | |
uses: actions/download-artifact@v3 | |
with: | |
name: sitemap | |
path: tmp | |
- name: Unzip Sitemap | |
run: unzip -o tmp/sitemap -d sitemap | |
- name: Push backup to reference.geoconnex.us | |
uses: DevOpenWRT-Router/github-action-push-to-another-repository@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
with: | |
source-directory: sitemap | |
destination-repository-name: internetofwater/reference.geoconnex.us | |
target-branch: main | |
target-directory: sitemap | |
user-email: [email protected] | |
user-name: webb-ben |